PAR-16
Ability to customize the exception-based error messages in the plugins by using message keys rather than strings
Goal
Let plugins throw exceptions that carry a message key resolved against the plugin's messages, instead of a hard-coded human string — e.g. throw new PermissionError("treasury.error.no-permission").
Grounded
Hibernia's CommandManager (hibernia-framework/.../commander/CommandManager.java) already maps its built-in exceptions to fixed keys (NoPermissionException → hibernia.error.no-permission, BadCommandException → hibernia.error.bad-command, plus NotFoundException/ConflictException/ExceedsLimitException) and renders them via the injected Message bean (sendError / handleInvocationFailure, ~lines 489–534). But a thrown exception's own getMessage() is treated as a literal string — there's no way to pass a plugin-specific message key + placeholders.
Fix
- Add a
LocalizableExceptioninterface exposinggetMessageKey()+getPlaceholders(). - In
handleInvocationFailure/sendError, if the thrown exception isLocalizableException, resolve its key against the plugin'sMessagebean (with placeholders) rather than using the raw message. - Preserve current behaviour for plain exceptions (back-compat).
Acceptance
- A plugin can
throw new SomeError(messageKey, placeholders…)and HF renders the resolved, localized message from that plugin's properties. - Existing built-in error keys still work.
Comments
No comments yet.
Activity
- tesks description: Description updated
- paradaux changed status to Status → Planned
- tesks assigned Assigned to rian