Skip to content

Taxum / @taxum/core / http / StatusCode

Class: StatusCode

Defined in: http/status.ts:18

Represents HTTP status codes along with their standard reason phrases.

This class provides a set of constants corresponding to standard HTTP status codes, which are compliant with various RFC documents. It enables developers to use predefined instances for status codes and reason phrases, thus improving readability and reducing potential errors.

The StatusCode class implements the ToHttpResponse interface, which may provide additional functionality when interacting with HTTP responses.

Implements

Properties

code

readonly code: number

Defined in: http/status.ts:409


phrase

readonly phrase: string

Defined in: http/status.ts:410


ACCEPTED

readonly static ACCEPTED: StatusCode

Defined in: http/status.ts:53

202 Accepted [RFC9110, Section 15.3.3]


ALREADY_REPORTED

readonly static ALREADY_REPORTED: StatusCode

Defined in: http/status.ts:92

208 Already Reported [RFC5842, Section 7.1]


BAD_GATEWAY

readonly static BAD_GATEWAY: StatusCode

Defined in: http/status.ts:350

502 Bad Gateway [RFC9110, Section 15.6.3]


BAD_REQUEST

readonly static BAD_REQUEST: StatusCode

Defined in: http/status.ts:152

400 Bad Request [RFC9110, Section 15.5.1]


CONFLICT

readonly static CONFLICT: StatusCode

Defined in: http/status.ts:209

409 Conflict [RFC9110, Section 15.5.10]


CONTENT_TOO_LARGE

readonly static CONTENT_TOO_LARGE: StatusCode

Defined in: http/status.ts:233

413 Content Too Large [RFC9110, Section 15.5.14]


CONTINUE

readonly static CONTINUE: StatusCode

Defined in: http/status.ts:23

100 Continue [RFC9110, Section 15.2.1]


CREATED

readonly static CREATED: StatusCode

Defined in: http/status.ts:47

201 Created [RFC9110, Section 15.3.2]


EXPECTATION_FAILED

readonly static EXPECTATION_FAILED: StatusCode

Defined in: http/status.ts:260

417 Expectation Failed [RFC9110, Section 15.5.18]


FAILED_DEPENDENCY

readonly static FAILED_DEPENDENCY: StatusCode

Defined in: http/status.ts:290

424 Failed Dependency [RFC4918, Section 11.4]


FORBIDDEN

readonly static FORBIDDEN: StatusCode

Defined in: http/status.ts:170

403 Forbidden [RFC9110, Section 15.5.4]


FOUND

readonly static FOUND: StatusCode

Defined in: http/status.ts:116

302 Found [RFC9110, Section 15.4.3]


GATEWAY_TIMEOUT

readonly static GATEWAY_TIMEOUT: StatusCode

Defined in: http/status.ts:362

504 Gateway Timeout [RFC9110, Section 15.6.5]


GONE

readonly static GONE: StatusCode

Defined in: http/status.ts:215

410 Gone [RFC9110, Section 15.5.11]


HTTP_VERSION_NOT_SUPPORTED

readonly static HTTP_VERSION_NOT_SUPPORTED: StatusCode

Defined in: http/status.ts:368

505 HTTP Version Not Supported [RFC9110, Section 15.6.6]


IM_A_TEAPOT

readonly static IM_A_TEAPOT: StatusCode

Defined in: http/status.ts:266

418 I'm a teapot [RFC7168]


IM_USED

readonly static IM_USED: StatusCode

Defined in: http/status.ts:98

226 IM Used [RFC3229, Section 10.4.1]


INSUFFICIENT_STORAGE

readonly static INSUFFICIENT_STORAGE: StatusCode

Defined in: http/status.ts:386

507 Insufficient Storage [RFC4918, Section 11.5]


INTERNAL_SERVER_ERROR

readonly static INTERNAL_SERVER_ERROR: StatusCode

Defined in: http/status.ts:338

500 Internal Server Error [RFC9110, Section 15.6.1]


LENGTH_REQUIRED

readonly static LENGTH_REQUIRED: StatusCode

Defined in: http/status.ts:221

411 Length Required [RFC9110, Section 15.5.12]


LOCKED

readonly static LOCKED: StatusCode

Defined in: http/status.ts:284

423 Locked [RFC4918, Section 11.3]


LOOP_DETECTED

readonly static LOOP_DETECTED: StatusCode

Defined in: http/status.ts:392

508 Loop Detected [RFC5842, Section 7.2]


METHOD_NOT_ALLOWED

readonly static METHOD_NOT_ALLOWED: StatusCode

Defined in: http/status.ts:182

405 Method Not Allowed [RFC9110, Section 15.5.6]


MISDIRECTED_REQUEST

readonly static MISDIRECTED_REQUEST: StatusCode

Defined in: http/status.ts:272

421 Misdirected Request [RFC9110, Section 15.5.20]


MOVED_PERMANENTLY

readonly static MOVED_PERMANENTLY: StatusCode

Defined in: http/status.ts:110

301 Moved Permanently [RFC9110, Section 15.4.2]


MULTI_STATUS

readonly static MULTI_STATUS: StatusCode

Defined in: http/status.ts:86

207 Multi-Status [RFC4918, Section 11.1]


MULTIPLE_CHOICES

readonly static MULTIPLE_CHOICES: StatusCode

Defined in: http/status.ts:104

300 Multiple Choices [RFC9110, Section 15.4.1]


NETWORK_AUTHENTICATION_REQUIRED

readonly static NETWORK_AUTHENTICATION_REQUIRED: StatusCode

Defined in: http/status.ts:404

511 Network Authentication Required [RFC6585, Section 6]


NO_CONTENT

readonly static NO_CONTENT: StatusCode

Defined in: http/status.ts:68

204 No Content [RFC9110, Section 15.3.5]


NON_AUTHORITATIVE_INFORMATION

readonly static NON_AUTHORITATIVE_INFORMATION: StatusCode

Defined in: http/status.ts:59

203 Non-Authoritative Information [RFC9110, Section 15.3.4]


NOT_ACCEPTABLE

readonly static NOT_ACCEPTABLE: StatusCode

Defined in: http/status.ts:188

406 Not Acceptable [RFC9110, Section 15.5.7]


NOT_EXTENDED

readonly static NOT_EXTENDED: StatusCode

Defined in: http/status.ts:398

510 Not Extended [RFC2774, Section 7]


NOT_FOUND

readonly static NOT_FOUND: StatusCode

Defined in: http/status.ts:176

404 Not Found [RFC9110, Section 15.5.5]


NOT_IMPLEMENTED

readonly static NOT_IMPLEMENTED: StatusCode

Defined in: http/status.ts:344

501 Not Implemented [RFC9110, Section 15.6.2]


NOT_MODIFIED

readonly static NOT_MODIFIED: StatusCode

Defined in: http/status.ts:128

304 Not Modified [RFC9110, Section 15.4.5]


OK

readonly static OK: StatusCode

Defined in: http/status.ts:41

200 OK [RFC9110, Section 15.3.1]


PARTIAL_CONTENT

readonly static PARTIAL_CONTENT: StatusCode

Defined in: http/status.ts:80

206 Partial Content [RFC9110, Section 15.3.7]


PAYMENT_REQUIRED

readonly static PAYMENT_REQUIRED: StatusCode

Defined in: http/status.ts:164

402 Payment Required [RFC9110, Section 15.5.3]


PERMANENT_REDIRECT

readonly static PERMANENT_REDIRECT: StatusCode

Defined in: http/status.ts:146

308 Permanent Redirect [RFC9110, Section 15.4.8]


PRECONDITION_FAILED

readonly static PRECONDITION_FAILED: StatusCode

Defined in: http/status.ts:227

412 Precondition Failed [RFC9110, Section 15.5.13]


PRECONDITION_REQUIRED

readonly static PRECONDITION_REQUIRED: StatusCode

Defined in: http/status.ts:308

428 Precondition Required [RFC6585, Section 3]


PROCESSING

readonly static PROCESSING: StatusCode

Defined in: http/status.ts:35

102 Processing [RFC2518, Section 10.1]


PROXY_AUTHENTICATION_REQUIRED

readonly static PROXY_AUTHENTICATION_REQUIRED: StatusCode

Defined in: http/status.ts:194

407 Proxy Authentication Required [RFC9110, Section 15.5.8]


RANGE_NOT_SATISFIABLE

readonly static RANGE_NOT_SATISFIABLE: StatusCode

Defined in: http/status.ts:254

416 Range Not Satisfiable [RFC9110, Section 15.5.17]


REQUEST_HEADER_FIELDS_TOO_LARGE

readonly static REQUEST_HEADER_FIELDS_TOO_LARGE: StatusCode

Defined in: http/status.ts:320

431 Request Header Fields Too Large [RFC6585, Section 5]


REQUEST_TIMEOUT

readonly static REQUEST_TIMEOUT: StatusCode

Defined in: http/status.ts:203

408 Request Timeout [RFC9110, Section 15.5.9]


RESET_CONTENT

readonly static RESET_CONTENT: StatusCode

Defined in: http/status.ts:74

205 Reset Content [RFC9110, Section 15.3.6]


SEE_OTHER

readonly static SEE_OTHER: StatusCode

Defined in: http/status.ts:122

303 See Other [RFC9110, Section 15.4.4]


SERVICE_UNAVAILABLE

readonly static SERVICE_UNAVAILABLE: StatusCode

Defined in: http/status.ts:356

503 Service Unavailable [RFC9110, Section 15.6.4]


SWITCHING_PROTOCOLS

readonly static SWITCHING_PROTOCOLS: StatusCode

Defined in: http/status.ts:29

101 Switching Protocols [RFC9110, Section 15.2.2]


TEMPORARY_REDIRECT

readonly static TEMPORARY_REDIRECT: StatusCode

Defined in: http/status.ts:140

307 Temporary Redirect [RFC9110, Section 15.4.7]


TOO_EARLY

readonly static TOO_EARLY: StatusCode

Defined in: http/status.ts:296

425 Too Early [RFC8470, Section 5.2]


TOO_MANY_REQUESTS

readonly static TOO_MANY_REQUESTS: StatusCode

Defined in: http/status.ts:314

429 Too Many Requests [RFC6585, Section 4]


UNAUTHORIZED

readonly static UNAUTHORIZED: StatusCode

Defined in: http/status.ts:158

401 Unauthorized [RFC9110, Section 15.5.2]


readonly static UNAVAILABLE_FOR_LEGAL_REASONS: StatusCode

Defined in: http/status.ts:329

451 Unavailable For Legal Reasons [RFC7725]


UNPROCESSABLE_CONTENT

readonly static UNPROCESSABLE_CONTENT: StatusCode

Defined in: http/status.ts:278

422 Unprocessable Content [RFC9110, Section 15.5.21]


UNSUPPORTED_MEDIA_TYPE

readonly static UNSUPPORTED_MEDIA_TYPE: StatusCode

Defined in: http/status.ts:245

415 Unsupported Media Type [RFC9110, Section 15.5.16]


UPGRADE_REQUIRED

readonly static UPGRADE_REQUIRED: StatusCode

Defined in: http/status.ts:302

426 Upgrade Required [RFC9110, Section 15.5.22]


URI_TOO_LONG

readonly static URI_TOO_LONG: StatusCode

Defined in: http/status.ts:239

414 URI Too Long [RFC9110, Section 15.5.15]


USE_PROXY

readonly static USE_PROXY: StatusCode

Defined in: http/status.ts:134

305 Use Proxy [RFC9110, Section 15.4.6]


VARIANT_ALSO_NEGOTIATES

readonly static VARIANT_ALSO_NEGOTIATES: StatusCode

Defined in: http/status.ts:377

506 Variant Also Negotiates [RFC2295, Section 8.1]

Methods

[TO_HTTP_RESPONSE]()

[TO_HTTP_RESPONSE](): HttpResponse

Defined in: http/status.ts:478

Returns

HttpResponse

Implementation of

ToHttpResponse.[TO_HTTP_RESPONSE]


isClientError()

isClientError(): boolean

Defined in: http/status.ts:466

Determines if the current HTTP status code falls within the client error response range (400-499).

Returns

boolean


isInformational()

isInformational(): boolean

Defined in: http/status.ts:442

Determines if the current HTTP status code falls within the informational response range (100-199).

Returns

boolean


isRedirection()

isRedirection(): boolean

Defined in: http/status.ts:458

Determines if the current HTTP status code falls within the redirection response range (300-399).

Returns

boolean


isServerError()

isServerError(): boolean

Defined in: http/status.ts:474

Determines if the current HTTP status code falls within the server error response range (500-599).

Returns

boolean


isSuccess()

isSuccess(): boolean

Defined in: http/status.ts:450

Determines if the current HTTP status code falls within the success response range (200-299).

Returns

boolean


toJSON()

toJSON(): number

Defined in: http/status.ts:482

Returns

number


fromCode()

static fromCode(code): StatusCode

Defined in: http/status.ts:428

Converts a numeric code to its corresponding StatusCode.

Parameters

code

number

Returns

StatusCode

Throws

if the provided code is not defined in the code map.