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>
Default implementation of
Note: cannot be called
IError.Note: cannot be called
Error because this would conflict with
the default Java Exception class.- Since:
- 8.5.0
- Author:
- Philip Helger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSingleError.AbstractBuilder<ERRTYPE extends SingleError,IMPLTYPE extends SingleError.AbstractBuilder<ERRTYPE, IMPLTYPE>> Abstract builder class forSingleErrorand derived classes.static final classThe default builder to buildSingleErrorinstances. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSingleError(SingleError.AbstractBuilder<?, ?> aBuilder) Constructor for the Builder only.SingleError(LocalDateTime aErrorDT, IErrorLevel aErrorLevel, String sErrorID, String sErrorFieldName, ILocation aErrorLocation, IHasErrorText aErrorText, Throwable aLinkedException) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic SingleError.Builderbuilder()Create a new empty error builder with the default error level fromSingleError.Builder.static SingleError.BuilderCreate a new error builder containing all the data from the provided error.static SingleError.BuilderCreate a new empty error builder with the ERROR error level.static SingleError.BuilderCreate a new empty error builder with the FATAL ERROR error level.static SingleError.BuilderCreate a new empty error builder with the INFO error level.static SingleError.BuilderCreate a new empty error builder with the SUCCESS error level.static SingleError.BuilderCreate a new empty error builder with the WARN error level.booleanprotected booleanequalsLinkedException(Throwable t1, Throwable t2) Overridable implementation of Throwable for the Linked exception field.inthashCode()protected voidOverridable implementation of Throwable for the Linked exception field.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.error.IError
getAsString, getAsStringLocaleIndepdent, getErrorText, getLinkedExceptionCause, getLinkedExceptionMessage, getLinkedExceptionStackTrace, hasErrorDateTime, hasErrorLocation, hasLinkedExceptionMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsTMethods inherited from interface com.helger.commons.error.IHasErrorField
hasErrorFieldName, hasErrorFieldName, hasNoErrorFieldNameMethods inherited from interface com.helger.commons.error.IHasErrorID
hasErrorID, hasErrorID, hasNoErrorIDMethods inherited from interface com.helger.commons.error.level.IHasErrorLevel
hasErrorLevel, isError, isFailure, isNoError, isSuccessMethods inherited from interface com.helger.commons.error.level.IHasErrorLevelComparable
compareTo, isEQ, isGE, isGT, isLE, isLT, isNEMethods inherited from interface com.helger.commons.state.ISuccessIndicator
and, or
-
Constructor Details
-
SingleError
Constructor for the Builder only.- Parameters:
aBuilder- The builder to take the data from. May not benull.
-
SingleError
public SingleError(@Nullable LocalDateTime aErrorDT, @Nonnull IErrorLevel aErrorLevel, @Nullable String sErrorID, @Nullable String sErrorFieldName, @Nullable ILocation aErrorLocation, @Nullable IHasErrorText aErrorText, @Nullable Throwable aLinkedException) Constructor- Parameters:
aErrorDT- Error date timeaErrorLevel- Error level. May not benull.sErrorID- Error IDsErrorFieldName- Error field nameaErrorLocation- Error locationaErrorText- Error textaLinkedException- Linked exception- Since:
- 10.1.7
-
-
Method Details
-
getErrorDateTime
- Specified by:
getErrorDateTimein interfaceIError- Returns:
- The date and time when the error occurred. Defaults to
nullfor backwards compatibility.
-
getErrorLevel
- Specified by:
getErrorLevelin interfaceIHasErrorLevel- Returns:
- The error level of this object. May not be
null.
-
getErrorID
Description copied from interface:IError- Specified by:
getErrorIDin interfaceIError- Specified by:
getErrorIDin interfaceIHasErrorID- Returns:
- The error ID. May be
null.
-
getErrorFieldName
- Specified by:
getErrorFieldNamein interfaceIError- Specified by:
getErrorFieldNamein interfaceIHasErrorField- Returns:
- The field for which the error occurred. May be
null.
-
getErrorLocation
- Specified by:
getErrorLocationin interfaceIError- Returns:
- The non-
nulllocation of the error. UseSimpleLocation.NO_LOCATIONto indicate no location is available. - See Also:
-
getErrorTexts
- Specified by:
getErrorTextsin interfaceIError- Returns:
- The contained error message text. May be
null. - See Also:
-
getLinkedException
- Specified by:
getLinkedExceptionin interfaceIError- Returns:
- The linked exception or
nullif no such exception is available. - See Also:
-
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)
-
equals
-
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.
-
hashCode
public int hashCode() -
toString
-
builder
Create a new empty error builder with the default error level fromSingleError.Builder.- Returns:
- A new Error builder. Never
null.
-
builder
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
Create a new empty error builder with the SUCCESS error level.- Returns:
- A new Error builder with default error level
EErrorLevel.SUCCESS. Nevernull.
-
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
Create a new empty error builder with the WARN error level.- Returns:
- A new Error builder with default error level
EErrorLevel.WARN. Nevernull.
-
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
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.
-