Interface ErrorContext.Source

All Known Subinterfaces:
DeserializeContext, DeserializeInput
Enclosing interface:
ErrorContext

public static interface ErrorContext.Source
A source of error contexts.

This class might be implemented in different places, and therefore provide different context keys in returned ErrorContexts.

  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull ErrorContext
    buildError(@NonNull Printable message)
    Builds an error context based on the implementation.
    @NonNull Locale
    The locale to format error messages in.
    <R> @NonNull LoadResult<R>
    throwError(@NonNull CharSequence message)
    Builds an error context, wraps it in a LoadResult and returns it.
    <R> @NonNull LoadResult<R>
    throwError(@NonNull Printable message)
    Builds an error context, wraps it in a LoadResult and returns it.
  • Method Details

    • getLocale

      @NonNull Locale getLocale()
      The locale to format error messages in.
      Returns:
      the locale
    • buildError

      @NonNull ErrorContext buildError(@NonNull Printable message)
      Builds an error context based on the implementation.

      This function takes a Printable for flexibility. Using Printable.preBuilt(CharSequence) will suffice in many cases.

      Parameters:
      message - the main error messge
      Returns:
      an error context
    • throwError

      <R> @NonNull LoadResult<R> throwError(@NonNull CharSequence message)
      Builds an error context, wraps it in a LoadResult and returns it.

      This function does not actually throw anything. It is named as such so that your code can look like this:

           
               return operable.throwError("failure");
           
       
      Type Parameters:
      R - the type of the result value (can be anything since the result will be an error)
      Parameters:
      message - the main error message
      Returns:
      an error result
    • throwError

      <R> @NonNull LoadResult<R> throwError(@NonNull Printable message)
      Builds an error context, wraps it in a LoadResult and returns it.

      This function does not actually throw anything. It is named as such to communicate the logical termination of a block of code.

      Type Parameters:
      R - the type of the result value (can be anything since the result will be an error)
      Parameters:
      message - the main error message
      Returns:
      an error result