UNPKG

1.83 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const http_exception_1 = require("./http.exception");
4const http_status_enum_1 = require("../enums/http-status.enum");
5/**
6 * Defines an HTTP exception for *Gatway Timeout* type errors.
7 *
8 * @see [Base Exceptions](https://docs.nestjs.com/exception-filters#base-exceptions)
9 *
10 * @publicApi
11 */
12class GatewayTimeoutException extends http_exception_1.HttpException {
13 /**
14 * Instantiate a `GatewayTimeoutException` Exception.
15 *
16 * @example
17 * `throw new GatewayTimeoutException()`
18 *
19 * @usageNotes
20 * The constructor arguments define the HTTP response.
21 * - The `message` argument defines the JSON response body.
22 * - The `error` argument defines the HTTP Status Code.
23 *
24 * By default, the JSON response body contains two properties:
25 * - `statusCode`: defaults to the Http Status Code provided in the `error` argument
26 * - `message`: the string `'Gateway Timeout'` by default; override this by supplying
27 * a string in the `message` parameter.
28 *
29 * To override the entire JSON response body, pass an object. Nest will serialize
30 * the object and return it as the JSON response body.
31 *
32 * The `error` argument is required, and should be a valid HTTP status code.
33 * Best practice is to use the `HttpStatus` enum imported from `nestjs/common`.
34 *
35 * @param message string or object describing the error condition.
36 * @param error HTTP response status code
37 */
38 constructor(message, error = 'Gateway Timeout') {
39 super(http_exception_1.HttpException.createBody(message, error, http_status_enum_1.HttpStatus.GATEWAY_TIMEOUT), http_status_enum_1.HttpStatus.GATEWAY_TIMEOUT);
40 }
41}
42exports.GatewayTimeoutException = GatewayTimeoutException;