Package space.arim.dazzleconf
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.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA marker for context keysstatic interfaceA source of error contexts. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ErrorContext.Key<Printable> Error message provided by the configuration format backendstatic final ErrorContext.Key<KeyPath> Path of the configuration entry being scanned or operated uponstatic final ErrorContext.Key<Integer> Line number in the source datastatic final ErrorContext.Key<URL> A URL pointing to an online syntax linter. -
Method Summary
Modifier and TypeMethodDescription<V> voidaddDetail(@NonNull ErrorContext.Key<V> key, @NonNull V context) Adds a piece of detail to this error context, overriding previous values.@NonNull Set<@NonNull ErrorContext.Key<?>> allKeys()Gets all the keys set on this error context.voidclearDetail(@NonNull ErrorContext.Key<?> key) Clears the specified context for this error contextvoidcopyDetailsInto(@NonNull ErrorContext target) Copies all context details from this error context into another one@NonNull Printabledisplay()Formats this error context and includes all information.@NonNull LocaleThe locale to format messages in.@NonNull PrintableGets the main message to display as the reason for this error.<V> @Nullable Vquery(@NonNull ErrorContext.Key<V> key) Gets a piece of detail from this error context, if it is set
-
Field Details
-
ENTRY_PATH
Path of the configuration entry being scanned or operated upon -
LINE_NUMBER
Line number in the source data -
BACKEND_MESSAGE
Error message provided by the configuration format backend -
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 seedisplay().- 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
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
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 keycontext- the context detail to set- Throws:
NullPointerException- if the key or context detail is null
-
clearDetail
Clears the specified context for this error context- Parameters:
key- the key
-
copyDetailsInto
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
-