Klasse Error<None>

java.lang.Object
de.srsoftware.tools.Error<None>
Typparameter:
None - This result is not expected to carry a payload in the sense of a positive execution result.
Alle implementierten Schnittstellen:
Result<None>

public class Error<None> extends Object implements Result<None>
This class may be returned by methods whose execution failed. It may carry additional data about the cause of the failure
  • Konstruktordetails

    • Error

      public Error(String message)
      create a new Error object carrying the passed message
      Parameter:
      message - the message to add to the Error object
  • Methodendetails

    • add

      public Error<None> add(Exception exception)
      add an exception to this Error object
      Parameter:
      exception - the exception to add
      Gibt zurück:
      this object
    • addData

      public Error<None> addData(Object... tokens)
      Add values to the data map
      Parameter:
      tokens - a list of objects. The even elements are used as key in the data map, the odd ones as values.
      Gibt zurück:
      this Error object
    • data

      public Map<String,Object> data()
      return the data map
      Gibt zurück:
      metadata added to this Error object
    • exceptions

      public List<Exception> exceptions()
      get the list of Exceptions added to this Error object
      Gibt zurück:
      the list of Exceptions
    • format

      public static <None> Error<None> format(String message, Object... fills)
      create a new Error object with the message formatted with the given fills
      Typparameter:
      None - any type
      Parameter:
      message - a message string, which may contain placeholders
      fills - the objects to replace the placeholders
      Gibt zurück:
      a new Error object populated with the formatted message
    • json

      public org.json.JSONObject json()
      Create a json object of the error.
      Gibt zurück:
      the json object describing the error.
    • map

      public <Mapped> Result<Mapped> map(Function<Result<None>,Result<Mapped>> mapper)
      Beschreibung aus Schnittstelle kopiert: Result
      Transform this Result object to another via a mapping function.
      Angegeben von:
      map in Schnittstelle Result<None>
      Typparameter:
      Mapped - the payload type of the result of the mapping function
      Parameter:
      mapper - a function, that processes results and produces results
      Gibt zurück:
      the result of the mapping function
    • of

      public static <None> Error<None> of(String message, Exception... exceptions)
      create a new Error object carrying the passed message
      Typparameter:
      None - any type
      Parameter:
      message - the message to add to the Error object
      exceptions - exceptions to be added to the errors metadata
      Gibt zurück:
      a new Error object populated with the passed message
    • optional

      public Optional<None> optional()
      Beschreibung aus Schnittstelle kopiert: Result
      Create an Optional from a Result.
      Angegeben von:
      optional in Schnittstelle Result<None>
      Gibt zurück:
      An optional containing the Result`s content, if set.
    • stream

      public <Inner> Stream<Result<Inner>> stream()
      Beschreibung aus Schnittstelle kopiert: Result
      Create a stream of the Payload. This may be suitable, if the payload is a collection.
      Angegeben von:
      stream in Schnittstelle Result<None>
      Typparameter:
      Inner - the type of the payloads of the elements of the stream
      Gibt zurück:
      a stream of results
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object
    • transform

      public <NewType> Error<NewType> transform()
      create an Error with the same metadata content as this Object, but with different payload type
      Typparameter:
      NewType - the payload type of the returned error
      Gibt zurück:
      the transformed Error (new object)
    • wrap

      public Optional<Error<None>> wrap()
      Wrap an error object as Optional
      Gibt zurück:
      an Optional carrying this Error object