Package space.arim.dazzleconf
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 TypeMethodDescription@NonNull ErrorContextbuildError(@NonNull Printable message) Builds an error context based on the implementation.@NonNull LocaleThe locale to format error messages in.<R> @NonNull LoadResult<R> throwError(@NonNull CharSequence message) Builds an error context, wraps it in aLoadResultand returns it.<R> @NonNull LoadResult<R> throwError(@NonNull Printable message) Builds an error context, wraps it in aLoadResultand returns it.
-
Method Details
-
getLocale
@NonNull Locale getLocale()The locale to format error messages in.- Returns:
- the locale
-
buildError
Builds an error context based on the implementation.This function takes a
Printablefor flexibility. UsingPrintable.preBuilt(CharSequence)will suffice in many cases.- Parameters:
message- the main error messge- Returns:
- an error context
-
throwError
Builds an error context, wraps it in aLoadResultand 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
Builds an error context, wraps it in aLoadResultand 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
-