Stratal API Reference
    Preparing search index...

    Class GlobalErrorHandler

    GlobalErrorHandler

    Centralized error handler registered in the DI container. Responsible for:

    • Intercepting all errors in the application
    • Logging errors with appropriate severity via Logger service
    • Translating error message keys using I18nService (when available)
    • Serializing errors for RPC transmission
    • Wrapping unexpected errors in InternalError

    Translation Availability by Context:

    HTTP Requests: Errors are fully translated

    • GlobalErrorHandler resolved from request container
    • I18nService available via AsyncLocalStorage with user's locale
    • Full translation with parameter interpolation

    Queue Processing: Errors are fully translated

    • Error handling executes inside AsyncLocalStorage scope
    • Locale extracted from queue message metadata
    • Request container created with mock RouterContext
    • I18nService available with correct locale

    ⚠️ RPC/Startup: Message keys returned as-is (i18n unavailable)

    • No request context available during service binding or startup
    • No locale information available
    • Frontend can translate message keys using its own i18n if needed
    • This is expected behavior, not a bug

    Implementation Note: The isAvailable() check exists to gracefully handle RPC/startup contexts where no request container exists. For HTTP and Queue contexts, i18n is always available thanks to AsyncLocalStorage scope propagation. This follows the "Laravel philosophy" - transparent dependency injection for request contexts, with explicit handling only for legitimate non-request edge cases.

    Index

    Constructors

    Methods

    Constructors

    Methods