Skip to content

Logging Element API errors #117

@oddnavy

Description

@oddnavy

Is there a way to log exceptions caught in the element-api actionIndex? The code looks like it catches exceptions thrown.

https://github.com/craftcms/element-api/blob/v2/src/controllers/DefaultController.php#L165

For context, we want to log exceptions that cause 500s in my element-api to Rollbar.

Current code to log exceptions:

Event::on(
  ErrorHandler::class,
  ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
  function (ExceptionEvent $event) {
    Rollbar::error($event->exception);
  }
);

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