exception

Classes

default

Base Exception class for all Treehouse-specifc API Exception.

AuthorizationException

Exception used when a request fails security or authorization checks to prompt the User or Client to refresh their session, or to indicate to other services to act similarly.

Exception

ApiException provides a message and stack trace as Exception does, but also provides a response status and an error code for use in production debugging/support.

InternalException
Thrown when an unhandled or unrecoverable exception is encountered.
InvalidRequestException

Generic exception used to signal to a User/Client that their request was invalid.

ServiceUnavailableException

Exception indicating that an external or internal service is unreachable or unavailable.

Members

(inner) DEFAULT_FATAL_ERROR :string

Default error message to surface to clients for unrecoverable errors.

Default error message to surface to clients for unrecoverable errors.

Source:

(inner) DEFAULT_FORBIDDEN :string

Default error to surface to requests that are forbidden to make that request.

Default error to surface to requests that are forbidden to make that request.

Source:

(inner) DEFAULT_GENERAL_ERROR :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding with a generalized 400 error.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding with a generalized 400 error.

Source:

(inner) DEFAULT_INVALID_REQUEST :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding to an invalid request.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding to an invalid request.

Source:

(inner) DEFAULT_SERVICE_UNAVAILABLE :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when a service is not available.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when a service is not available.

Source:

(inner) DEFAULT_UNAUTHORIZED :string

Default error message to surface to clients when they are no longer authorized to access a particular resource or service.

Default error message to surface to clients when they are no longer authorized to access a particular resource or service.

Source:

(inner) DEFAULT_VALIDATION_ERROR :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when validating a request fails.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when validating a request fails.

Source:

(inner) FATAL_ERROR :function

Factory to generate a 500 Error Message payload from the provided message.

Factory to generate a 500 Error Message payload from the provided message. Message defaults to DEFAULT_FATAL_ERROR.

{
  status: 500,
  code: -1,
  category: 'IllegalStateException',
  message,
}
Source:

(inner) FORBIDDEN :function

Forbidden (403) Error Factory.

Forbidden (403) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_FORBIDDEN if no message is provided. Returns the payload:

{
  status: 403,
  code: 5,
  category: 'SecurityException',
  message,
}
Source:

(inner) GENERAL_ERROR :function

Factory to generate a 400 Error Message payload from the provided message.

Factory to generate a 400 Error Message payload from the provided message. Message defaults to DEFAULT_GENERAL_ERROR.

{
  status: 400,
  code: '0a',
  category: 'GeneralException',
  message,
}
Source:

(inner) ILLEGAL_STATE_EXCEPTION :function

Illegal State Exception (500) Error Factory.

Illegal State Exception (500) Error Factory. Returns the payload:

{
  status: 500,
  code: 2,
  category: 'IllegalStateException',
  message: 'Application not configured correctly',
}
Source:

(inner) INVALID_REQUEST :function

Invalid Request (400) Error Factory.

Invalid Request (400) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_INVALID_REQUEST if no message is provided. Returns the payload:

{
  status: 400,
  code: 3,
  category: 'UserError',
  message,
}
Source:

(inner) MISSING_REQUIRED_PARAMETER :function

Missing Required Request Parameter (malformed request) (400) Error Factory.

Missing Required Request Parameter (malformed request) (400) Error Factory. Returns the payload:

{
  status: 400,
  code: 6,
  category: 'GeneralException',
  message: 'A required parameter was missing',
}
Source:

(inner) NOT_YET_IMPLEMENTED :function

Not Yet Implemented (501) Error Factory.

Not Yet Implemented (501) Error Factory. Returns the payload:

{
  status: 501,
  code: 1,
  category: 'NotYetImplemented',
  message: 'This method must be implmented',
}
Source:

(inner) SERVICE_UNAVAILABLE :function

Service Unavailable (503) Error Factory.

Service Unavailable (503) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_SERVICE_UNAVAILABLE if no message is provided. Returns the payload:

{
  status: 503,
  code: 7,
  category: 'NetworkException',
  message,
}
Source:

(inner) UNAUTHORIZED :function

Unauthorized (401) Error Factory.

Unauthorized (401) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_UNAUTHORIZED if no message is provided. Returns the payload:

{
  status: 401,
  code: 4,
  category: 'SecurityException',
  message,
}
Source:

(inner) VALIDATION_ERROR :function

Validation Failure (400) Error Factory.

Validation Failure (400) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_VALIDATION_ERROR if no message is provided. Returns the payload:

{
  status: 400,
  code: 8,
  category: 'ValidationException',
  message,
}
Source:

Methods

(inner) resolveCode(payload) → {number}

Attempts to find the code in the provided payload if the payload is an object.

Attempts to find the code in the provided payload if the payload is an object. If the payload is a number, then payload is returned. Otherwise, DEFAULT_CODE is returned.

Parameters:
Name Type Description
payload number | Object
Source:

(inner) resolveMessage(payload) → {string}

Attempts to find the message in the provided payload if the payload is an object.

Attempts to find the message in the provided payload if the payload is an object. If the payload is a string, then payload is returned. Otherwise, DEFAULT_MESSAGE is returned.

Parameters:
Name Type Description
payload string | Object
Source:

(inner) resolveStatus(payload) → {number}

Attempts to find the status in the provided payload if the payload is an object.

Attempts to find the status in the provided payload if the payload is an object. If the payload is a number, then payload is returned. Otherwise, DEFAULT_STATUS is returned.

Parameters:
Name Type Description
payload number | Object
Source:

Classes

default

Base Exception class for all Treehouse-specifc API Exception.

AuthorizationException

Exception used when a request fails security or authorization checks to prompt the User or Client to refresh their session, or to indicate to other services to act similarly.

Exception

ApiException provides a message and stack trace as Exception does, but also provides a response status and an error code for use in production debugging/support.

InternalException
Thrown when an unhandled or unrecoverable exception is encountered.
InvalidRequestException

Generic exception used to signal to a User/Client that their request was invalid.

ServiceUnavailableException

Exception indicating that an external or internal service is unreachable or unavailable.

Members

(inner) DEFAULT_FATAL_ERROR :string

Default error message to surface to clients for unrecoverable errors.

Default error message to surface to clients for unrecoverable errors.

Source:

(inner) DEFAULT_FORBIDDEN :string

Default error to surface to requests that are forbidden to make that request.

Default error to surface to requests that are forbidden to make that request.

Source:

(inner) DEFAULT_GENERAL_ERROR :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding with a generalized 400 error.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding with a generalized 400 error.

Source:

(inner) DEFAULT_INVALID_REQUEST :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding to an invalid request.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding to an invalid request.

Source:

(inner) DEFAULT_SERVICE_UNAVAILABLE :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when a service is not available.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when a service is not available.

Source:

(inner) DEFAULT_UNAUTHORIZED :string

Default error message to surface to clients when they are no longer authorized to access a particular resource or service.

Default error message to surface to clients when they are no longer authorized to access a particular resource or service.

Source:

(inner) DEFAULT_VALIDATION_ERROR :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when validating a request fails.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when validating a request fails.

Source:

(inner) FATAL_ERROR :function

Factory to generate a 500 Error Message payload from the provided message.

Factory to generate a 500 Error Message payload from the provided message. Message defaults to DEFAULT_FATAL_ERROR.

{
  status: 500,
  code: -1,
  category: 'IllegalStateException',
  message,
}
Source:

(inner) FORBIDDEN :function

Forbidden (403) Error Factory.

Forbidden (403) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_FORBIDDEN if no message is provided. Returns the payload:

{
  status: 403,
  code: 5,
  category: 'SecurityException',
  message,
}
Source:

(inner) GENERAL_ERROR :function

Factory to generate a 400 Error Message payload from the provided message.

Factory to generate a 400 Error Message payload from the provided message. Message defaults to DEFAULT_GENERAL_ERROR.

{
  status: 400,
  code: '0a',
  category: 'GeneralException',
  message,
}
Source:

(inner) ILLEGAL_STATE_EXCEPTION :function

Illegal State Exception (500) Error Factory.

Illegal State Exception (500) Error Factory. Returns the payload:

{
  status: 500,
  code: 2,
  category: 'IllegalStateException',
  message: 'Application not configured correctly',
}
Source:

(inner) INVALID_REQUEST :function

Invalid Request (400) Error Factory.

Invalid Request (400) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_INVALID_REQUEST if no message is provided. Returns the payload:

{
  status: 400,
  code: 3,
  category: 'UserError',
  message,
}
Source:

(inner) MISSING_REQUIRED_PARAMETER :function

Missing Required Request Parameter (malformed request) (400) Error Factory.

Missing Required Request Parameter (malformed request) (400) Error Factory. Returns the payload:

{
  status: 400,
  code: 6,
  category: 'GeneralException',
  message: 'A required parameter was missing',
}
Source:

(inner) NOT_YET_IMPLEMENTED :function

Not Yet Implemented (501) Error Factory.

Not Yet Implemented (501) Error Factory. Returns the payload:

{
  status: 501,
  code: 1,
  category: 'NotYetImplemented',
  message: 'This method must be implmented',
}
Source:

(inner) SERVICE_UNAVAILABLE :function

Service Unavailable (503) Error Factory.

Service Unavailable (503) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_SERVICE_UNAVAILABLE if no message is provided. Returns the payload:

{
  status: 503,
  code: 7,
  category: 'NetworkException',
  message,
}
Source:

(inner) UNAUTHORIZED :function

Unauthorized (401) Error Factory.

Unauthorized (401) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_UNAUTHORIZED if no message is provided. Returns the payload:

{
  status: 401,
  code: 4,
  category: 'SecurityException',
  message,
}
Source:

(inner) VALIDATION_ERROR :function

Validation Failure (400) Error Factory.

Validation Failure (400) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_VALIDATION_ERROR if no message is provided. Returns the payload:

{
  status: 400,
  code: 8,
  category: 'ValidationException',
  message,
}
Source:

Methods

(inner) resolveCode(payload) → {number}

Attempts to find the code in the provided payload if the payload is an object.

Attempts to find the code in the provided payload if the payload is an object. If the payload is a number, then payload is returned. Otherwise, DEFAULT_CODE is returned.

Parameters:
Name Type Description
payload number | Object
Source:

(inner) resolveMessage(payload) → {string}

Attempts to find the message in the provided payload if the payload is an object.

Attempts to find the message in the provided payload if the payload is an object. If the payload is a string, then payload is returned. Otherwise, DEFAULT_MESSAGE is returned.

Parameters:
Name Type Description
payload string | Object
Source:

(inner) resolveStatus(payload) → {number}

Attempts to find the status in the provided payload if the payload is an object.

Attempts to find the status in the provided payload if the payload is an object. If the payload is a number, then payload is returned. Otherwise, DEFAULT_STATUS is returned.

Parameters:
Name Type Description
payload number | Object
Source:

Classes

default

Base Exception class for all Treehouse-specifc API Exception.

AuthorizationException

Exception used when a request fails security or authorization checks to prompt the User or Client to refresh their session, or to indicate to other services to act similarly.

Exception

ApiException provides a message and stack trace as Exception does, but also provides a response status and an error code for use in production debugging/support.

InternalException
Thrown when an unhandled or unrecoverable exception is encountered.
InvalidRequestException

Generic exception used to signal to a User/Client that their request was invalid.

ServiceUnavailableException

Exception indicating that an external or internal service is unreachable or unavailable.

Members

(inner) DEFAULT_FATAL_ERROR :string

Default error message to surface to clients for unrecoverable errors.

Default error message to surface to clients for unrecoverable errors.

Source:

(inner) DEFAULT_FORBIDDEN :string

Default error to surface to requests that are forbidden to make that request.

Default error to surface to requests that are forbidden to make that request.

Source:

(inner) DEFAULT_GENERAL_ERROR :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding with a generalized 400 error.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding with a generalized 400 error.

Source:

(inner) DEFAULT_INVALID_REQUEST :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding to an invalid request.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when responding to an invalid request.

Source:

(inner) DEFAULT_SERVICE_UNAVAILABLE :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when a service is not available.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when a service is not available.

Source:

(inner) DEFAULT_UNAUTHORIZED :string

Default error message to surface to clients when they are no longer authorized to access a particular resource or service.

Default error message to surface to clients when they are no longer authorized to access a particular resource or service.

Source:

(inner) DEFAULT_VALIDATION_ERROR :string

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when validating a request fails.

Whimsical default error message to surface to clients when no additional Error details are available or should be obfuscated when validating a request fails.

Source:

(inner) FATAL_ERROR :function

Factory to generate a 500 Error Message payload from the provided message.

Factory to generate a 500 Error Message payload from the provided message. Message defaults to DEFAULT_FATAL_ERROR.

{
  status: 500,
  code: -1,
  category: 'IllegalStateException',
  message,
}
Source:

(inner) FORBIDDEN :function

Forbidden (403) Error Factory.

Forbidden (403) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_FORBIDDEN if no message is provided. Returns the payload:

{
  status: 403,
  code: 5,
  category: 'SecurityException',
  message,
}
Source:

(inner) GENERAL_ERROR :function

Factory to generate a 400 Error Message payload from the provided message.

Factory to generate a 400 Error Message payload from the provided message. Message defaults to DEFAULT_GENERAL_ERROR.

{
  status: 400,
  code: '0a',
  category: 'GeneralException',
  message,
}
Source:

(inner) ILLEGAL_STATE_EXCEPTION :function

Illegal State Exception (500) Error Factory.

Illegal State Exception (500) Error Factory. Returns the payload:

{
  status: 500,
  code: 2,
  category: 'IllegalStateException',
  message: 'Application not configured correctly',
}
Source:

(inner) INVALID_REQUEST :function

Invalid Request (400) Error Factory.

Invalid Request (400) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_INVALID_REQUEST if no message is provided. Returns the payload:

{
  status: 400,
  code: 3,
  category: 'UserError',
  message,
}
Source:

(inner) MISSING_REQUIRED_PARAMETER :function

Missing Required Request Parameter (malformed request) (400) Error Factory.

Missing Required Request Parameter (malformed request) (400) Error Factory. Returns the payload:

{
  status: 400,
  code: 6,
  category: 'GeneralException',
  message: 'A required parameter was missing',
}
Source:

(inner) NOT_YET_IMPLEMENTED :function

Not Yet Implemented (501) Error Factory.

Not Yet Implemented (501) Error Factory. Returns the payload:

{
  status: 501,
  code: 1,
  category: 'NotYetImplemented',
  message: 'This method must be implmented',
}
Source:

(inner) SERVICE_UNAVAILABLE :function

Service Unavailable (503) Error Factory.

Service Unavailable (503) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_SERVICE_UNAVAILABLE if no message is provided. Returns the payload:

{
  status: 503,
  code: 7,
  category: 'NetworkException',
  message,
}
Source:

(inner) UNAUTHORIZED :function

Unauthorized (401) Error Factory.

Unauthorized (401) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_UNAUTHORIZED if no message is provided. Returns the payload:

{
  status: 401,
  code: 4,
  category: 'SecurityException',
  message,
}
Source:

(inner) VALIDATION_ERROR :function

Validation Failure (400) Error Factory.

Validation Failure (400) Error Factory. Generates an Error payload with the provided message, defaulting DEFAULT_VALIDATION_ERROR if no message is provided. Returns the payload:

{
  status: 400,
  code: 8,
  category: 'ValidationException',
  message,
}
Source:

Methods

(inner) resolveCode(payload) → {number}

Attempts to find the code in the provided payload if the payload is an object.

Attempts to find the code in the provided payload if the payload is an object. If the payload is a number, then payload is returned. Otherwise, DEFAULT_CODE is returned.

Parameters:
Name Type Description
payload number | Object
Source:

(inner) resolveMessage(payload) → {string}

Attempts to find the message in the provided payload if the payload is an object.

Attempts to find the message in the provided payload if the payload is an object. If the payload is a string, then payload is returned. Otherwise, DEFAULT_MESSAGE is returned.

Parameters:
Name Type Description
payload string | Object
Source:

(inner) resolveStatus(payload) → {number}

Attempts to find the status in the provided payload if the payload is an object.

Attempts to find the status in the provided payload if the payload is an object. If the payload is a number, then payload is returned. Otherwise, DEFAULT_STATUS is returned.

Parameters:
Name Type Description
payload number | Object
Source: