Errors

Portable and localizable Exceptions classes. Each Exception has a unique string code and details array (which can be used for creating localized strings), in addition to a description and stack trace .

Important points

  • There are three ways to use these classes:

    1. Using an existing exception class.
    2. Creating a child class that extends ApplicationException.
    3. Wrapping an exception in an existing application exception.
  • Although the exception classes themselves are not serializable, they can be converted to ErrorDescriptions, which are serializable in one language, transferred to the receiving side, and deserialized in another language. After deserialization, the initial exception class can be restored.

  • When transferring an exception from one language to another, the exception type that is closest to the initial exception type is chosen from the exceptions available in the target language.


Classes

ApplicationException

Defines a base class to defive various application exceptions. Most languages have own definition of base exception (error) types. However, this class is implemented symmetrically in all languages supported by PipServices toolkit. It allows to create portable implementations and support proper error propagation in microservices calls.

ApplicationExceptionFactory

Factory to recreate exceptions from ErrorDescription values passed through the wire.

BadRequestException

Errors due to improper user requests. For example: missing or incorrect parameters.

ConfigException

Errors related to mistakes in the microservice’s user-defined configurations.

ConflictException

Errors raised by conflicts between object versions that were posted by the user and those that are stored on the server.

ConnectionException

Errors that occur during connections to remote services. They can be related to misconfiguration, network issues, or the remote service itself.

ErrorCategory

Defines standard error categories supported by PipServices toolkit.

ErrorDescription

Serializeable error description. It is use to pass information about errors between microservices implemented in different languages. On the receiving side ErrorDescription is used to recreate exception object close to its original type without missing additional details.

ErrorDescriptionFactory

Factory used to create serializeable ErrorDescription from ApplicationException or from arbitrary errors. The ErrorDescriptions are used to pass errors through the wire between microservices implemented in different languages. They allow to restore exceptions on the receiving side close to the original type and preserve additional information.

FileException

A helper class to parameters from “options” configuration section.

InternalException

Errors caused by programming mistakes.

InvalidStateException

Errors related to calling operations, which require the component to be in a specific state. For instance: business calls when the component is not ready.

InvocationException

Errors returned by remote services or by the network during call attempts.

NotFoundException

Errors caused by attempts to access missing objects.

UnauthorizedException

Access errors caused by missing user identity (authentication error) or incorrect security permissions (authorization error).

UnknownException

Unknown or unexpected errors.

UnsupportedException

Errors caused by calls to unsupported or not yet implemented functionality.