Interface ErrorContext


public interface ErrorContext
Context holder for errors in LoadResult. This is a decorator around a type safe map, used to provide different error-related information and parts of context.
  • Field Details

    • ENTRY_PATH

      static final ErrorContext.Key<KeyPath> ENTRY_PATH
      Path of the configuration entry being scanned or operated upon
    • LINE_NUMBER

      static final ErrorContext.Key<Integer> LINE_NUMBER
      Line number in the source data
    • BACKEND_MESSAGE

      static final ErrorContext.Key<Printable> BACKEND_MESSAGE
      Error message provided by the configuration format backend
    • SYNTAX_LINTER

      @API(status=EXPERIMENTAL) static final ErrorContext.Key<URL> SYNTAX_LINTER
      A URL pointing to an online syntax linter.

      If the backend wishes, it can provide this URL, to an online syntax linter, to help the user check what's wrong.

  • Method Details

    • getLocale

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

      @NonNull Printable mainMessage()
      Gets the main message to display as the reason for this error. This won't include additional details; for that see display().
      Returns:
      the message
    • display

      @NonNull Printable display()
      Formats this error context and includes all information. This message is user displayable, and it is also intended to be sufficiently informative to avert the need for stacktraces.
      Returns:
      a displayable message
    • query

      <V> @Nullable V query(@NonNull ErrorContext.Key<V> key)
      Gets a piece of detail from this error context, if it is set
      Type Parameters:
      V - the value put in for the key
      Parameters:
      key - the key
      Returns:
      the context detail if set, or null if not present
    • addDetail

      <V> void addDetail(@NonNull ErrorContext.Key<V> key, @NonNull V context)
      Adds a piece of detail to this error context, overriding previous values.

      The passed context detail is copied and stored immutably in this error context. For example, lists are made into immutable copies.

      Type Parameters:
      V - the value put in for the key
      Parameters:
      key - the key
      context - the context detail to set
      Throws:
      NullPointerException - if the key or context detail is null
    • clearDetail

      void clearDetail(@NonNull ErrorContext.Key<?> key)
      Clears the specified context for this error context
      Parameters:
      key - the key
    • copyDetailsInto

      void copyDetailsInto(@NonNull ErrorContext target)
      Copies all context details from this error context into another one
      Parameters:
      target - the target error context
    • allKeys

      @NonNull Set<@NonNull ErrorContext.Key<?>> allKeys()
      Gets all the keys set on this error context.

      Implementations of this method are encouraged to provide stable, deterministic sorting of the returned set. Mutability is not defined, and callers should not try to modify it.

      Returns:
      all the keys, may or may not be immutable