@shadmanZero/tenantos-api
    Preparing search index...

    Class TenantosAuthenticationError

    Thrown when authentication fails

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    name: string = 'TenantosAuthenticationError'
    requestId?: string

    Unique request identifier for tracking (optional)

    response?: unknown

    Raw response data from the API (optional)

    statusCode: number

    HTTP status code from the response

    Methods

    • Get a user-friendly error message based on the HTTP status code

      This method provides human-readable error messages for common HTTP status codes, making it easier to display meaningful error information to users.

      Returns string

      A user-friendly error message string

      try {
      await client.servers.get(999);
      } catch (error) {
      if (error instanceof TenantosApiError) {
      alert(error.getUserMessage()); // Shows user-friendly message
      }
      }
    • Check if this is a client error (4xx status codes)

      Client errors indicate issues with the request such as invalid parameters, authentication failures, or requesting non-existent resources.

      Returns boolean

      True if the status code is in the 4xx range

      if (error.isClientError()) {
      console.log('Request error - check your parameters');
      }
    • Check if this is a server error (5xx status codes)

      Server errors indicate issues on the TenantOS server side and are typically temporary. These errors may be retryable depending on the specific status code.

      Returns boolean

      True if the status code is in the 5xx range

      if (error.isServerError()) {
      console.log('Server error - may be temporary, consider retrying');
      }
    • Check if this error has a specific HTTP status code

      Parameters

      • code: number

        The HTTP status code to check for

      Returns boolean

      True if the error status matches the provided code

      if (error.isStatus(404)) {
      console.log('Resource not found');
      } else if (error.isStatus(429)) {
      console.log('Rate limit exceeded');
      }