UNPKG

1.98 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ServiceUnavailableException = void 0;
4const http_status_enum_1 = require("../enums/http-status.enum");
5const http_exception_1 = require("./http.exception");
6/**
7 * Defines an HTTP exception for *Service Unavailable* type errors.
8 *
9 * @see [Base Exceptions](https://docs.nestjs.com/exception-filters#base-exceptions)
10 *
11 * @publicApi
12 */
13class ServiceUnavailableException extends http_exception_1.HttpException {
14 /**
15 * Instantiate a `ServiceUnavailableException` Exception.
16 *
17 * @example
18 * `throw new ServiceUnavailableException()`
19 *
20 * @usageNotes
21 * The HTTP response status code will be 503.
22 * - The `objectOrError` argument defines the JSON response body or the message string.
23 * - The `description` argument contains a short description of the HTTP error.
24 *
25 * By default, the JSON response body contains two properties:
26 * - `statusCode`: this will be the value 503.
27 * - `message`: the string `'Service Unavailable'` by default; override this by supplying
28 * a string in the `objectOrError` parameter.
29 *
30 * If the parameter `objectOrError` is a string, the response body will contain an
31 * additional property, `error`, with a short description of the HTTP error. To override the
32 * entire JSON response body, pass an object instead. Nest will serialize the object
33 * and return it as the JSON response body.
34 *
35 * @param objectOrError string or object describing the error condition.
36 * @param description a short description of the HTTP error.
37 */
38 constructor(objectOrError, description = 'Service Unavailable') {
39 super(http_exception_1.HttpException.createBody(objectOrError, description, http_status_enum_1.HttpStatus.SERVICE_UNAVAILABLE), http_status_enum_1.HttpStatus.SERVICE_UNAVAILABLE);
40 }
41}
42exports.ServiceUnavailableException = ServiceUnavailableException;