or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

extra-codes.mdindex.mdspecialty-modules.mdstandard-codes.mdstatus-classes.md
tile.json

status-classes.mddocs/

Status Code Classes

Classification system that groups HTTP status codes by their first digit, providing semantic meaning and class information for status code categorization.

Capabilities

Status Classes Object

The status classes provide a semantic grouping system for HTTP status codes based on their first digit.

/**
 * Status classes object providing classification for HTTP status codes
 */
interface StatusClasses {
  // Class identifiers - return class names
  "1xx": "Informational";
  "2xx": "Successful";
  "3xx": "Redirection";
  "4xx": "Client Error";
  "5xx": "Server Error";
  
  // Class name constants - return class identifiers
  INFORMATIONAL: "1xx";
  SUCCESSFUL: "2xx";
  REDIRECTION: "3xx";
  CLIENT_ERROR: "4xx";
  SERVER_ERROR: "5xx";
  
  // Class names - return uppercase constant names
  "1xx_NAME": "INFORMATIONAL";
  "2xx_NAME": "SUCCESSFUL";
  "3xx_NAME": "REDIRECTION";
  "4xx_NAME": "CLIENT_ERROR";
  "5xx_NAME": "SERVER_ERROR";
  
  // Class messages - return descriptive messages
  "1xx_MESSAGE": "Indicates an interim response for communicating connection status or request progress prior to completing the requested action and sending a final response.";
  "2xx_MESSAGE": "Indicates that the client's request was successfully received, understood, and accepted.";
  "3xx_MESSAGE": "Indicates that further action needs to be taken by the user agent in order to fulfill the request.";
  "4xx_MESSAGE": "Indicates that the client seems to have erred.";
  "5xx_MESSAGE": "Indicates that the server is aware that it has erred or is incapable of performing the requested method.";
}

Usage Examples:

import status from "http-status";

// Access class information
console.log(status.classes["2xx"]); // "Successful"
console.log(status.classes.SUCCESSFUL); // "2xx"
console.log(status.classes["2xx_NAME"]); // "SUCCESSFUL"
console.log(status.classes["2xx_MESSAGE"]); // "Indicates that the client's request was successfully received..."

// Use in switch statements for status code classification
const responseCode = 404;
const statusClass = status[`${responseCode}_CLASS`];

switch (statusClass) {
  case status.classes.INFORMATIONAL:
    console.log("Informational response");
    break;
  case status.classes.SUCCESSFUL:
    console.log("Success");
    break;
  case status.classes.REDIRECTION:
    console.log("Redirection required");
    break;
  case status.classes.CLIENT_ERROR:
    console.log("Client error");
    break;
  case status.classes.SERVER_ERROR:
    console.log("Server error");
    break;
}

Informational Class (1xx)

The 1xx class indicates an interim response for communicating connection status or request progress.

interface InformationalClass {
  "1xx": "Informational";
  INFORMATIONAL: "1xx";
  "1xx_NAME": "INFORMATIONAL";
  "1xx_MESSAGE": "Indicates an interim response for communicating connection status or request progress prior to completing the requested action and sending a final response.";
}

Examples:

  • 100 Continue
    - Server received request headers, client should proceed
  • 101 Switching Protocols
    - Server agrees to switch protocols
  • 102 Processing
    - Server is processing the request (WebDAV)
  • 103 Early Hints
    - Return response headers before final HTTP message

Successful Class (2xx)

The 2xx class indicates that the client's request was successfully received, understood, and accepted.

interface SuccessfulClass {
  "2xx": "Successful";
  SUCCESSFUL: "2xx";
  "2xx_NAME": "SUCCESSFUL";
  "2xx_MESSAGE": "Indicates that the client's request was successfully received, understood, and accepted.";
}

Examples:

  • 200 OK
    - Standard successful response
  • 201 Created
    - Request fulfilled, new resource created
  • 202 Accepted
    - Request accepted for processing
  • 204 No Content
    - Request processed, no content returned

Redirection Class (3xx)

The 3xx class indicates that further action needs to be taken by the user agent to fulfill the request.

interface RedirectionClass {
  "3xx": "Redirection";
  REDIRECTION: "3xx";
  "3xx_NAME": "REDIRECTION";
  "3xx_MESSAGE": "Indicates that further action needs to be taken by the user agent in order to fulfill the request.";
}

Examples:

  • 301 Moved Permanently
    - Resource permanently moved to new URL
  • 302 Found
    - Resource temporarily moved
  • 304 Not Modified
    - Resource not modified since last request
  • 307 Temporary Redirect
    - Request should be repeated with another URI

Client Error Class (4xx)

The 4xx class indicates that the client seems to have erred.

interface ClientErrorClass {
  "4xx": "Client Error";
  CLIENT_ERROR: "4xx";
  "4xx_NAME": "CLIENT_ERROR";
  "4xx_MESSAGE": "Indicates that the client seems to have erred.";
}

Examples:

  • 400 Bad Request
    - Malformed request syntax
  • 401 Unauthorized
    - Authentication required
  • 403 Forbidden
    - Server refuses to authorize request
  • 404 Not Found
    - Requested resource not found
  • 418 I'm a teapot
    - Easter egg status code

Server Error Class (5xx)

The 5xx class indicates that the server is aware that it has erred or is incapable of performing the requested method.

interface ServerErrorClass {
  "5xx": "Server Error";
  SERVER_ERROR: "5xx";
  "5xx_NAME": "SERVER_ERROR";
  "5xx_MESSAGE": "Indicates that the server is aware that it has erred or is incapable of performing the requested method.";
}

Examples:

  • 500 Internal Server Error
    - Generic server error
  • 501 Not Implemented
    - Server doesn't support the functionality
  • 502 Bad Gateway
    - Invalid response from upstream server
  • 503 Service Unavailable
    - Server temporarily unavailable
  • 504 Gateway Timeout
    - Upstream server timeout