adonisjs-exceptions

Create AdonisJS exceptions with static factories and HTTP responses.

2|1|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-exceptions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adonisjs-exceptions
Source: https://github.com/omakei/adonisjs-architecture-skill/tree/main/adonisjs/skills/adonisjs-exceptions
Command: npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-exceptions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Custom exceptions with static factories and self-contained HTTP responses standardize error handling in AdonisJS applications, ensuring consistent messages, statuses, and reusable patterns across services and controllers.

Core Features & Use Cases

  • Static factory methods for descriptive, contextual errors.
  • Self-contained HTTP response handling via handle() and structured reporting via report().
  • Clear guidance for organizing exceptions in app/exceptions/ with per-exception behavior.

Quick Start

Create a new OrderException by extending the base Exception, add static factories for each failure, and implement handle() to return a per-error HTTP response.

Frequently Asked Questions about adonisjs-exceptions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle domain errors with custom HTTP responses in AdonisJS?

Domain error handling in AdonisJS is managed by creating self-contained exceptions with static factories. Each exception implements handle() to return structured HTTP responses and report() for logging, ensuring consistent status codes and messages across service layers.

What is the best way to standardize exception messages in AdonisJS controllers and services?

Standardizing exception messages in AdonisJS is achieved by extending a base Exception class with static factory methods. This pattern encapsulates descriptive, contextual errors and reusable response behaviors directly within the exception definitions stored in app/exceptions/.

How do I create custom exceptions with static factory methods in AdonisJS?

To create custom exceptions in AdonisJS, extend the base Exception class and add static factory methods for each specific failure scenario. Implement handle() to define per-error HTTP responses and report() for structured logging of invalid states.

Can I use self-contained exceptions for business rule violations in AdonisJS service layers?

Yes, self-contained exceptions are designed for AdonisJS service and action layers where business rules and invalid states must throw rich, structured errors. They provide static factories to generate contextual domain errors with consistent codes and messages.

Does AdonisJS exception handling support per-exception logging?

AdonisJS exception handling supports per-exception logging through the report() method. This structured reporting mechanism ensures that domain errors are logged consistently while handle() separately manages the HTTP response output.

Why do I need static factory methods for AdonisJS exception handling?

Static factory methods for AdonisJS exceptions provide descriptive, contextual errors for specific failure scenarios. They standardize error creation by encapsulating business rules, ensuring consistent messages and reusable patterns across services and controllers.