Interface StructureError

All Known Implementing Classes:
StructureErrors

@PublicApi @PublicSpi public interface StructureError

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:
  • Method Details

    • getCode

      int getCode()
      Returns error code.
    • getCategory

      StructureErrorCategory getCategory()
      Returns error category.
    • name

      @NotNull default String 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

      default boolean is(StructureErrorCategory category)
      Checks if the error is of the given category.
      Parameters:
      category - the category
      Returns:
      true if this error belongs to the category
    • isOneOf

      default boolean isOneOf(StructureErrorCategory... categories)
      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

      default boolean isOneOf(StructureError... errors)
      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

      @NotNull default StructureException.Builder builder()
      Creates a new builder for StructureException with this code.
      Returns:
      StructureException builder
    • withLocalizedMessage

      @NotNull default StructureException withLocalizedMessage(@NotNull String messageKey, Object... messageParameters)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      messageKey - i18n key for the localized error message
      messageParameters - optional i18n message parameters
      Returns:
      exception with this code ready to be thrown
    • withMessage

      @NotNull default StructureException withMessage(@Nullable String message)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      message - non-internationalized message
      Returns:
      exception with this code ready to be thrown
    • withoutMessage

      @NotNull default StructureException withoutMessage()
      A shortcut to calling the same method on StructureException builder.
      Returns:
      exception with this code ready to be thrown
    • forStructure

      @NotNull default StructureException.Builder forStructure(@Nullable Long structure)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      structure - related structure ID
      Returns:
      StructureException builder
    • forView

      @NotNull default StructureException.Builder forView(@Nullable Long view)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      view - related view ID
      Returns:
      StructureException builder
    • forRow

      @NotNull default StructureException.Builder forRow(@Nullable Long row)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      row - related row ID
      Returns:
      StructureException builder
    • forItem

      @NotNull default StructureException.Builder forItem(@Nullable ItemIdentity item)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      item - related item ID
      Returns:
      StructureException builder
    • forIssue

      @NotNull default StructureException.Builder forIssue(long issueId)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      issueId - related issue ID
      Returns:
      StructureException builder
    • causedBy

      @NotNull default StructureException.Builder causedBy(@Nullable Throwable cause)
      A shortcut to calling the same method on StructureException builder.
      Parameters:
      cause - an exception that caused to problem
      Returns:
      StructureException builder