Interface StructureError
- All Known Implementing Classes:
StructureErrors
StructureError
implementations are wrappers around numeric error codes, which also
provide the error's category (see StructureErrorCategory
) and error name.
This lets the client code distinguish between multiple cases where
StructureException
can be thrown.
StructureError
may also be used to conveniently start a construction of StructureException
.
All public error codes are listed in StructureErrors
.
Implementation Notes
StructureError
is an interface to allow addition of new error codes without the need
to adjust previously released classes. Structure plugin may have unpublished internal error codes
and Structure extensions may have a collection of their own.
When assigning numeric value to a new error code, please mind that numbers 0—9999 are reserved by ALM Works for Structure and Structure extensions.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic @interface
Auxiliary annotation, which may be used on a collection ofStructureError
instances to specify the inclusive range of error codes that is taken by that collection. -
Method Summary
Modifier and TypeMethodDescriptiondefault StructureException.Builder
builder()
Creates a new builder forStructureException
with this code.default StructureException.Builder
A shortcut to calling the same method onStructureException
builder.default StructureException.Builder
forIssue
(long issueId) A shortcut to calling the same method onStructureException
builder.default StructureException.Builder
forItem
(ItemIdentity item) A shortcut to calling the same method onStructureException
builder.default StructureException.Builder
A shortcut to calling the same method onStructureException
builder.default StructureException.Builder
forStructure
(Long structure) A shortcut to calling the same method onStructureException
builder.default StructureException.Builder
A shortcut to calling the same method onStructureException
builder.Returns error category.int
getCode()
Returns error code.default boolean
is
(StructureErrorCategory category) Checks if the error is of the given category.default boolean
isOneOf
(StructureError... errors) Checks if the error is actually one of the provided variants.default boolean
isOneOf
(StructureErrorCategory... categories) Checks if the error belongs to one of the given categories.default String
name()
Returns error name.default StructureException
withLocalizedMessage
(String messageKey, Object... messageParameters) A shortcut to calling the same method onStructureException
builder.default StructureException
withMessage
(String message) A shortcut to calling the same method onStructureException
builder.default StructureException
A shortcut to calling the same method onStructureException
builder.
-
Method Details
-
getCode
int getCode()Returns error code. -
getCategory
StructureErrorCategory getCategory()Returns error category. -
name
Returns error name. The name is not supposed to tell end-user anything, it is not i18n-ized and can only be written as a diagnostic information. -
is
Checks if the error is of the given category.- Parameters:
category
- the category- Returns:
- true if this error belongs to the category
-
isOneOf
Checks if the error belongs to one of the given categories.- Parameters:
categories
- categories- Returns:
- true if this error belongs to one of the categories
-
isOneOf
Checks if the error is actually one of the provided variants.- Parameters:
errors
- errors to compare to- Returns:
- true if this error is equal to one of the passed errors
-
builder
Creates a new builder forStructureException
with this code.- Returns:
StructureException
builder
-
withLocalizedMessage
@NotNull default StructureException withLocalizedMessage(@NotNull String messageKey, Object... messageParameters) A shortcut to calling the same method onStructureException
builder.- Parameters:
messageKey
- i18n key for the localized error messagemessageParameters
- optional i18n message parameters- Returns:
- exception with this code ready to be thrown
-
withMessage
A shortcut to calling the same method onStructureException
builder.- Parameters:
message
- non-internationalized message- Returns:
- exception with this code ready to be thrown
-
withoutMessage
A shortcut to calling the same method onStructureException
builder.- Returns:
- exception with this code ready to be thrown
-
forStructure
A shortcut to calling the same method onStructureException
builder.- Parameters:
structure
- related structure ID- Returns:
StructureException
builder
-
forView
A shortcut to calling the same method onStructureException
builder.- Parameters:
view
- related view ID- Returns:
StructureException
builder
-
forRow
A shortcut to calling the same method onStructureException
builder.- Parameters:
row
- related row ID- Returns:
StructureException
builder
-
forItem
A shortcut to calling the same method onStructureException
builder.- Parameters:
item
- related item ID- Returns:
StructureException
builder
-
forIssue
A shortcut to calling the same method onStructureException
builder.- Parameters:
issueId
- related issue ID- Returns:
StructureException
builder
-
causedBy
A shortcut to calling the same method onStructureException
builder.- Parameters:
cause
- an exception that caused to problem- Returns:
StructureException
builder
-