Skip to content

Catch ModelNotFoundException #45

@Anahkiasen

Description

@Anahkiasen

I'm using repositories to share logic between the API and the application, when I query for a model and it doesn't exist it uses findOrFail which throws a Illuminate\Database\Eloquent\ModelNotFoundException. The problem is, at its core this extension extends the core's RuntimeException instead of a Symfony HTTP Exception so it's not caught by the API's exception handler. How would I go about to catch it globally without wrapping every single one of my methods in a try catch ?

I saw an API::error method but I'm unsure as to how it's meant to be used, would that be it ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions