Error Handling¶
Exceptions¶
JDA-Commands defines a set of custom runtime exceptions that can occur:
ConfigurationExceptionwill be thrown if anything goes wrong while configuring JDA-CommandsInvalidDeclarationExceptionwill be thrown if any errors are made in the declaration of interactionsParsingExceptionwill be thrown if the JSON parsing of the Embed API failsInternalExceptionwill be thrown if anything goes wrong internally. These errors should be reported to the devs
If a ConfigurationException
or InvalidDeclarationException
occurs during startup, JDA-Commands will shut down itself as well as JDA. To disable this behaviour, set JDACBuilder#shutdownJDA(boolean)
to false.
Error Messages¶
As mentioned before, JDA-Commands has a set of error messages it uses all over the place. These messages include:
- Command Execution Failed Message (used for Exceptions)
- Constraint Failed Message (see Validators)
- Insufficient Permissions Message (see Permissions System)
- Timed Out Component Message (see Runtime Concept)
- Type Adapting Failed Message (see Type Adapters)
Localization¶
For simple localization of these error messages you can add a jdac_LOCALE.ftl file to the resources folder and
provide the keys/ use the variables as listed below.
Type Adapting Failed¶

Keys
adapting-failed-titleadapting-failed-detailsadapting-failed-message
Variables
command: The full command with parameter names, with the failed argument underlined, for instance: /example arg1 ^^arg2^^expected: The expected argument typeactual: The provided argument typeraw: The raw, textual user inputmessage: The error message of the type adapter
Insufficient Permissions¶

Keys
insufficient-permissions
Variables
interaction: The name of the interaction that failedpermissions: The permissions that are required
Constraint Failed¶

Keys
constraint-failed
Variables
message: The already localized error message of the failed constraint
Interaction Execution Failed¶

Keys
execution-failed-title-
execution-failed-messageVariables -
user: the user executing the interaction interaction: the interaction typetimestamp: the current timestampexception: the name of the exception class
Unknown Interaction¶

Keys
unknown-interaction
You can find the default fluent file here.
Own Implementation¶
You can customize these error messages by providing an implementation of ErrorMessageFactory either at the builder or
by annotating it with @Implementation.