UNPKG

rfc9457

Version:

RFC 9457 Problem Details for HTTP APIs - A standardized error handling package for Node.js

23 lines 763 B
import { HttpError } from "../../core/index.js"; import { extractCause, getErrorType, normalizeToString, } from "../../helpers/index.js"; export class PayloadTooLargeError extends HttpError { maxSize; constructor(detail, maxSize) { super({ type: getErrorType("payload-too-large"), title: "Payload Too Large", status: 413, detail: normalizeToString(detail), cause: extractCause(detail), }); this.name = "PayloadTooLargeError"; this.maxSize = maxSize; } toJSON() { return { ...super.toJSON(), ...(this.maxSize !== undefined && { maxSize: this.maxSize }), }; } } //# sourceMappingURL=payload-too-large-error.js.map