SWAGcommands
API reference

Error catalog

The exported error types and the phases they describe.

Every framework error extends SwagError. Its code, phase, context, and cause help you log a useful report without parsing a message string.

ExportTypical source
InitializationErrorLocal loading or startup failed
ModuleLoadErrorA file could not be loaded
CommandDefinitionErrorA command shape or manifest is invalid
CommandDeploymentErrorDiscord application-command sync failed
CommandExecutionErrorA command callback failed
InteractionResponseErrorReply, deferral, or edit failed
InteractionAlreadyAcknowledgedErrorA second acknowledgement was attempted
MessageResponseErrorMessage send, reply, or typing failed
AutocompleteErrorAutocomplete callback or respond() failed
EventExecutionErrorEvent callback or filter failed
PreconditionExecutionErrorGuard execution or failure hook failed
FeatureDefinitionErrorFeature file shape or name is invalid
FeatureExecutionErrorA one-time or recurring feature failed
FeatureCleanupErrorA feature cleanup function failed

ErrorPhase includes initialization, deployment, validation, execution, response, autocomplete, and event. ErrorContext may include a command, subcommand, event, file, feature, invocation kind, deployment scope, or guild ID depending on the error. Check the fields you need rather than assuming every error has every field.

SWAG.create(), startFeatures(), stopFeatures(), and deployment methods can reject directly. Runtime callback failures go to onError (or the logger if no hook is set). A normal precondition denial goes to onPreconditionFailure, not necessarily onError. See Errors and reporting.