Class ErrorDescriptionFactory

java.lang.Object
org.pipservices3.commons.errors.ErrorDescriptionFactory

public class ErrorDescriptionFactory extends Object
Factory 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.

See Also:
  • Constructor Details

    • ErrorDescriptionFactory

      public ErrorDescriptionFactory()
  • Method Details

    • create

      public static ErrorDescription create(Exception ex)
      Creates a serializable ErrorDescription from error object.
      Parameters:
      ex - an error object
      Returns:
      a serializeable ErrorDescription object that describes the error.
    • create

      public static ErrorDescription create(Throwable ex, String correlationId)
      Creates a serializable ErrorDescription from throwable object with unknown error category.
      Parameters:
      ex - an error object
      correlationId - (optional) a unique transaction id to trace execution through call chain.
      Returns:
      a serializeable ErrorDescription object that describes the error.