@ExperimentalApi public class ErrorCollection extends Object
If the caller is a REST service, it will normally render the errors for the client to display.
The ErrorCollection can contain two types of errors: - global errors : these are not bound to a particular context, and will normally be displayed on a neutral, central place on the page - contextual errors : these are bound to a particular context, and the client will decide where to show them (e.g. next to a form field)
| Modifier and Type | Class and Description |
|---|---|
static class |
ErrorCollection.ErrorItem |
static class |
ErrorCollection.Reason
Copied from JIRA's ErrorCollection interface.
|
| Constructor and Description |
|---|
ErrorCollection() |
| Modifier and Type | Method and Description |
|---|---|
ErrorCollection |
addAllErrors(ErrorCollection toAdd) |
ErrorCollection |
addAllErrorsWithoutReason(ErrorCollection toAdd)
Add all errors from error collection without adding reasons.
|
ErrorCollection |
addContextualError(ErrorCollection.Reason reason,
String contextId,
String messageKey,
Object... params)
Add a contextual error.
|
ErrorCollection |
addContextualError(String contextId,
String messageKey,
Object... params)
Add a contextual error.
|
ErrorCollection |
addError(ErrorCollection.Reason reason,
String messageKey,
Object... params)
Add a global error that is not bound to a particular context.
|
ErrorCollection |
addError(String messageKey,
Object... params)
Add a global error that is not bound to a particular context.
|
ErrorCollection |
addReason(ErrorCollection.Reason reason)
Add a reason why the function has not been performed.
|
ErrorCollection |
addReasons(Set<ErrorCollection.Reason> reasons)
Add reasons why the function has not been performed.
|
void |
clear() |
static ErrorCollection |
fromJiraErrorCollection(com.atlassian.jira.util.ErrorCollection jiraErrors) |
static ErrorCollection |
fromJiraErrorCollectionWithReasons(com.atlassian.jira.util.ErrorCollection jiraErrors) |
List<ErrorCollection.ErrorItem> |
getContextualErrors(String contextId)
Get all errors for a particular context
|
ErrorCollection.Reason |
getDefinitiveReason()
Returns the definitive reason, if one exists.
|
Set<String> |
getErrorContextIds()
Get all contextIDs for which errors exist
|
List<ErrorCollection.ErrorItem> |
getErrors() |
List<ErrorCollection.ErrorItem> |
getGlobalErrors()
Get all errors that are not related to a context
|
Set<ErrorCollection.Reason> |
getReasons()
A set of well known reasons why the function has not been performed.
|
boolean |
hasErrors()
Check if there are any errors at all, global or contextual.
|
boolean |
hasGlobalErrors()
Check if there are any global errors
|
ErrorCollection |
setReasons(Set<ErrorCollection.Reason> reasons)
Set reasons why the function has not been performed.
|
String |
toString() |
public static ErrorCollection fromJiraErrorCollection(com.atlassian.jira.util.ErrorCollection jiraErrors)
public static ErrorCollection fromJiraErrorCollectionWithReasons(com.atlassian.jira.util.ErrorCollection jiraErrors)
public boolean hasErrors()
public boolean hasGlobalErrors()
public ErrorCollection addContextualError(String contextId, String messageKey, Object... params)
contextId - : an ID that gives the caller an indication what context this error relates to. An Ajax client will use this to decide where on the page the error should be displayed.messageKey - : the i18n message keyparams - : to be passed to i18nIllegalArgumentException - if messageKey is nullpublic ErrorCollection addContextualError(ErrorCollection.Reason reason, String contextId, String messageKey, Object... params)
reason - the reason for this errorcontextId - : an ID that gives the caller an indication what context this error relates to. An Ajax client will use this to decide where on the page the error should be displayed.messageKey - : the i18n message keyparams - : to be passed to i18nIllegalArgumentException - if messageKey is nullpublic ErrorCollection addError(String messageKey, Object... params)
messageKey - : the i18n message keyparams - : to be passed to i18nIllegalArgumentException - if messageKey is nullpublic ErrorCollection addError(ErrorCollection.Reason reason, String messageKey, Object... params)
reason - : the reason for this errormessageKey - : the i18n message keyparams - : to be passed to i18nIllegalArgumentException - if messageKey is nullpublic List<ErrorCollection.ErrorItem> getErrors()
public void clear()
public ErrorCollection addAllErrors(ErrorCollection toAdd)
public ErrorCollection addAllErrorsWithoutReason(ErrorCollection toAdd)
toAdd - an error collection which contains errors to add.public List<ErrorCollection.ErrorItem> getContextualErrors(String contextId)
public List<ErrorCollection.ErrorItem> getGlobalErrors()
public Set<String> getErrorContextIds()
public ErrorCollection addReasons(Set<ErrorCollection.Reason> reasons)
reasons - a set of well known reasons why the function has not been performed.public ErrorCollection addReason(ErrorCollection.Reason reason)
reason - a well known reasons why the function has not been performed.public ErrorCollection setReasons(Set<ErrorCollection.Reason> reasons)
reasons - a set of well known reasons why the function has not been performed.public Set<ErrorCollection.Reason> getReasons()
public ErrorCollection.Reason getDefinitiveReason()
Copyright © 2007–2025 Atlassian. All rights reserved.