Package com.helger.commons.error
Class SingleError
- java.lang.Object
-
- com.helger.commons.error.SingleError
-
- All Implemented Interfaces:
IError,IHasErrorField,IHasErrorID,IHasErrorLevel,IHasErrorLevelComparable<IError>,ISeverityComparable<IError>,IErrorIndicator,ISuccessIndicator,IGenericImplTrait<IError>,Serializable
@Immutable public class SingleError extends Object implements IError
Default implementation ofIError.
Note: cannot be calledErrorbecause this would conflict with the default Java Exception class.- Since:
- 8.5.0
- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSingleError.AbstractBuilder<T extends SingleError,IMPLTYPE extends SingleError.AbstractBuilder<T,IMPLTYPE>>Abstract builder class forSingleErrorand derived classes.static classSingleError.SingleErrorBuilder
-
Constructor Summary
Constructors Constructor Description SingleError(IErrorLevel aErrorLevel, String sErrorID, String sErrorFieldName, ILocation aErrorLocation, IHasErrorText aErrorText, Throwable aLinkedException)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SingleError.SingleErrorBuilderbuilder()Create a new empty error builder with the default error level fromSingleError.SingleErrorBuilder.static SingleError.SingleErrorBuilderbuilder(IError aError)Create a new error builder containing all the data from the provided error.static SingleError.SingleErrorBuilderbuilderError()Create a new empty error builder with the ERROR error level.static SingleError.SingleErrorBuilderbuilderFatalError()Create a new empty error builder with the FATAL ERROR error level.static SingleError.SingleErrorBuilderbuilderInfo()Create a new empty error builder with the INFO error level.static SingleError.SingleErrorBuilderbuilderSuccess()Create a new empty error builder with the SUCCESS error level.static SingleError.SingleErrorBuilderbuilderWarn()Create a new empty error builder with the WARN error level.booleanequals(Object o)protected booleanequalsLinkedException(Throwable t1, Throwable t2)Overridable implementation of Throwable for the Linked exception field.StringgetErrorFieldName()StringgetErrorID()IErrorLevelgetErrorLevel()ILocationgetErrorLocation()IHasErrorTextgetErrorTexts()ThrowablegetLinkedException()inthashCode()protected voidhashCodeLinkedException(HashCodeGenerator aHCG, Throwable t)Overridable implementation of Throwable for the Linked exception field.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.error.IError
getAsString, getErrorText, getLinkedExceptionCause, getLinkedExceptionMessage, getLinkedExceptionStackTrace, hasErrorLocation, hasLinkedException
-
Methods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsT
-
Methods inherited from interface com.helger.commons.error.IHasErrorField
hasErrorFieldName, hasErrorFieldName, hasNoErrorFieldName
-
Methods inherited from interface com.helger.commons.error.IHasErrorID
hasErrorID, hasErrorID, hasNoErrorID
-
Methods inherited from interface com.helger.commons.error.level.IHasErrorLevel
hasErrorLevel, isError, isFailure, isNoError, isSuccess
-
Methods inherited from interface com.helger.commons.error.level.IHasErrorLevelComparable
compareTo, isEQ, isGE, isGT, isLE, isLT, isNE
-
Methods inherited from interface com.helger.commons.state.ISuccessIndicator
and, or
-
-
-
-
Method Detail
-
getErrorLevel
@Nonnull public IErrorLevel getErrorLevel()
- Specified by:
getErrorLevelin interfaceIHasErrorLevel- Returns:
- The error level of this object. May not be
null.
-
getErrorID
@Nullable public String getErrorID()
Description copied from interface:IError- Specified by:
getErrorIDin interfaceIError- Specified by:
getErrorIDin interfaceIHasErrorID- Returns:
- The error ID. May be
null.
-
getErrorFieldName
@Nullable public String getErrorFieldName()
- Specified by:
getErrorFieldNamein interfaceIError- Specified by:
getErrorFieldNamein interfaceIHasErrorField- Returns:
- The field for which the error occurred. May be
null.
-
getErrorLocation
@Nonnull public ILocation getErrorLocation()
- Specified by:
getErrorLocationin interfaceIError- Returns:
- The non-
nulllocation of the error. UseSimpleLocation.NO_LOCATIONto indicate no location is available. - See Also:
IError.hasErrorLocation()
-
getErrorTexts
@Nullable public IHasErrorText getErrorTexts()
- Specified by:
getErrorTextsin interfaceIError- Returns:
- The contained error message text. May be
null. - See Also:
IError.getErrorText(Locale)
-
getLinkedException
@Nullable public Throwable getLinkedException()
- Specified by:
getLinkedExceptionin interfaceIError- Returns:
- The linked exception or
nullif no such exception is available. - See Also:
IError.hasLinkedException(),IError.getLinkedExceptionMessage(),IError.getLinkedExceptionStackTrace(),IError.getLinkedExceptionCause()
-
equalsLinkedException
@OverrideOnDemand protected boolean equalsLinkedException(@Nullable Throwable t1, @Nullable Throwable t2)
Overridable implementation of Throwable for the Linked exception field. This can be overridden to implement a different algorithm. This is customizable because there is no default way of comparing Exceptions in Java. If you override this method you must also overridehashCodeLinkedException(HashCodeGenerator, Throwable)!- Parameters:
t1- First Throwable. May benull.t2- Second Throwable. May benull.- Returns:
trueif they are equals (or both null)
-
hashCodeLinkedException
@OverrideOnDemand protected void hashCodeLinkedException(@Nonnull HashCodeGenerator aHCG, @Nullable Throwable t)
Overridable implementation of Throwable for the Linked exception field. This can be overridden to implement a different algorithm. This is customizable because there is no default way of hashing Exceptions in Java. If you override this method you must also overrideequalsLinkedException(Throwable, Throwable)!- Parameters:
aHCG- The hash code generator to append to. Nevernull.t- The Throwable to append. May benull.
-
builder
@Nonnull public static SingleError.SingleErrorBuilder builder()
Create a new empty error builder with the default error level fromSingleError.SingleErrorBuilder.- Returns:
- A new Error builder. Never
null.
-
builder
@Nonnull public static SingleError.SingleErrorBuilder builder(@Nonnull IError aError)
Create a new error builder containing all the data from the provided error.- Parameters:
aError- The error to copy the data from- Returns:
- A new Error builder containing all the data from the provided
error. Never
null.
-
builderSuccess
@Nonnull public static SingleError.SingleErrorBuilder builderSuccess()
Create a new empty error builder with the SUCCESS error level.- Returns:
- A new Error builder with default error level
EErrorLevel.SUCCESS. Nevernull.
-
builderInfo
@Nonnull public static SingleError.SingleErrorBuilder builderInfo()
Create a new empty error builder with the INFO error level.- Returns:
- A new Error builder with default error level
EErrorLevel.INFO. Nevernull.
-
builderWarn
@Nonnull public static SingleError.SingleErrorBuilder builderWarn()
Create a new empty error builder with the WARN error level.- Returns:
- A new Error builder with default error level
EErrorLevel.WARN. Nevernull.
-
builderError
@Nonnull public static SingleError.SingleErrorBuilder builderError()
Create a new empty error builder with the ERROR error level.- Returns:
- A new Error builder with default error level
EErrorLevel.ERROR. Nevernull.
-
builderFatalError
@Nonnull public static SingleError.SingleErrorBuilder builderFatalError()
Create a new empty error builder with the FATAL ERROR error level.- Returns:
- A new Error builder with default error level
EErrorLevel.FATAL_ERROR. Nevernull.
-
-