I'm working on some code that should fail quickly and loudly if things go wrong. It's part of the mailer and called via the API by the mailing create pages.

But I can't get the exception to end up in the log (with a stack trace hopefully!)

Surprisingly both SQL errors and the CRM_Core_Exception I'm throwing end up in the JS console!

Is there a setting to change this behavior? I don't see one under the debugging settings.



What you can do is call CRM_Core_Error::backtrace('some message', TRUE); before you throw the exception to get it to appear in the Civi log.

It might also work if you throw a regular \Exception instead of CRM_Core_Exception then it might end up in the web server log. But Civi API calls generally get caught and reformatted and then sent back to the caller (in this case js, hence they appear as js errors).

  • Thank you - very helpful!
    – Aaron
    Sep 15 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.