Interface GeneralProblems
- All Superinterfaces:
ProblemFactory
General purpose problems that can appear in many parts of the system. These are an alternative to, and an eventual
replacement for, problems coded up with StandardCodes
.
-
Method Summary
Modifier and TypeMethodDescriptionbadArity
(Class<?> arityThing, Object parent, com.google.common.collect.Range<Integer> expected, int actual) badListLength
(String expectedNumber, int actual) A list was provided, but it was expected to contain a certain number of elementsbadResource
(Class<?> expectedType, URI location) "Value '<value-provided>' for <named-thing> is invalid, it must be <some-constraint>" E.g.couldNotConvert
(String parameterName, Class<?> parameterType, String invalidValue) A problem suitable for wrapping a more specific parameter binding errordeprecated
(Object thing, Object replacement) When thing has be deprecated but is used.failedObjectLookedUp
(String id, Class<?> failedClass) Version offailedResourceLookedUp(String, Resource, Class)
where no resource (or the unknown resource) is available.failedResourceLookedUp
(String id, Resource resource, Class<?> failedClass) Produces an error for when a user has referenced and object by its id, but it has errors associated with it that mean it can't be used.failedToBuild
(Object thing) Failed to constructfrom the input provided failedToValidate
(Class<? extends Identified> kindOfThing, String id, Resource resource) When anIdentified
object has failed validationstatic GeneralProblems
get()
Useful non-specific method to group a bunch of problems when there's no specific parent issue.nameAlreadyUsedBy
(String id, Object usedBy, Class<?> thing) noSuchObjectExists
(String id, Class<?> clazz) Produces an error for when a user has referenced an object by its id and it doesn't existnoSuchObjectExistsDidYouMean
(String id, Class<? extends Identified> clazz, List<String> similarIds) notAnOption
(String value, Class<T> enumClass) Convenience version ofnotAnOption(String, Object, List)
for enums.notAnOption
(String value, Object context, List<?> possibleOptions) '' is not a valid option for . notAnOptionSimilarTo
(String value, List<?> similarOptions) When value is not a valid option.objectAlreadyExists
(String id, Class<?> identifiedClass) Produces an error for when a user to tries to add an object with an id that is already used, e.g.operationNotSupported
(String operation, Class clazz) For when an operation is called despite not being supported.precisionLoss
(Number from, Number to) Produces error: 'thing
' was required but not foundstatic Problem
Produces error: 'name
'typeOfThing
was required but not found.<T extends Comparable<?>>
ProblemvalueOutOfRange
(Object affected, T value, com.google.common.collect.Range<T> range) A given value was outside of an expected range.
-
Method Details
-
get
-
required
Produces error: '
name
'typeOfThing
was required but not found. This is a helper for when the required object doesn't actually exist yet. -
required
Produces error: '
thing
' was required but not found -
objectAlreadyExists
Produces an error for when a user to tries to add an object with an id that is already used, e.g. adding a function with the same id twice.
-
noSuchObjectExists
Produces an error for when a user has referenced an object by its id and it doesn't exist
-
noSuchObjectExistsDidYouMean
-
failedResourceLookedUp
Produces an error for when a user has referenced and object by its id, but it has errors associated with it that mean it can't be used. It's expected that the caller of this constructor append the failures to this problem
-
failedObjectLookedUp
Version of
failedResourceLookedUp(String, Resource, Class)
where no resource (or the unknown resource) is available. -
badResource
- Returns:
- a problem suitable for wrapping other problems caused by trying to build a type of thing from a resource
-
notAnOption
'
' is not a valid option for . Available options are: - '.
-
notAnOptionSimilarTo
When value is not a valid option. The similar options may be subset of those available. 'value' is not a valid option. Did you mean one of:
- '
-
operationNotSupported
For when an operation is called despite not being supported.
- Parameters:
operation
- up-supported operation that was calledclazz
- the class that does not support the operation
-
notAnOption
Convenience version of
notAnOption(String, Object, List)
for enums. Useful when a user supplied string doesn't match any of the values from the given enum -
couldNotConvert
A problem suitable for wrapping a more specific parameter binding error
-
failedToBuild
Failed to construct
from the input provided -
failedToValidate
When an
Identified
object has failed validation -
badListLength
A list was provided, but it was expected to contain a certain number of elements
-
deprecated
When thing has be deprecated but is used.
- Parameters:
thing
- that has been deprecatedreplacement
- the replacement for thing
-
multipleProblems
Problem multipleProblems()Useful non-specific method to group a bunch of problems when there's no specific parent issue. Use
Problems.toSingleProblem(List)
instead of this method. FYI We could avoid this kind of nonsense if we had a ProblemList type that abstracted over this, a bit like a NodeList in some xml libs -
precisionLoss
-
valueOutOfRange
<T extends Comparable<?>> Problem valueOutOfRange(Object affected, T value, com.google.common.collect.Range<T> range) A given value was outside of an expected range.
Could be a parameter or a function argument or any other place that user input is accepted, so this problem lives here rather than in one of the specific factories
-
badValue
"Value '<value-provided>' for <named-thing> is invalid, it must be <some-constraint>" E.g. "Value '0' for 'num-event-sets' parameter is invalid, it must be > 0"
-
badArity
-
nameAlreadyUsedBy
-