1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.PreconditionFailedException = void 0;
|
4 | const http_status_enum_1 = require("../enums/http-status.enum");
|
5 | const http_exception_1 = require("./http.exception");
|
6 | /**
|
7 | * Defines an HTTP exception for *Precondition Failed* type errors.
|
8 | *
|
9 | * @see [Built-in HTTP exceptions](https://docs.nestjs.com/exception-filters#built-in-http-exceptions)
|
10 | *
|
11 | * @publicApi
|
12 | */
|
13 | class PreconditionFailedException extends http_exception_1.HttpException {
|
14 | /**
|
15 | * Instantiate a `PreconditionFailedException` Exception.
|
16 | *
|
17 | * @example
|
18 | * `throw new PreconditionFailedException()`
|
19 | *
|
20 | * @usageNotes
|
21 | * The HTTP response status code will be 412.
|
22 | * - The `objectOrError` argument defines the JSON response body or the message string.
|
23 | * - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
24 | *
|
25 | * By default, the JSON response body contains two properties:
|
26 | * - `statusCode`: this will be the value 412.
|
27 | * - `message`: the string `'Precondition Failed'` 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 descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
37 | */
|
38 | constructor(objectOrError, descriptionOrOptions = 'Precondition Failed') {
|
39 | const { description, httpExceptionOptions } = http_exception_1.HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
40 | super(http_exception_1.HttpException.createBody(objectOrError, description, http_status_enum_1.HttpStatus.PRECONDITION_FAILED), http_status_enum_1.HttpStatus.PRECONDITION_FAILED, httpExceptionOptions);
|
41 | }
|
42 | }
|
43 | exports.PreconditionFailedException = PreconditionFailedException;
|