diff --git a/core/src/wheels/events/onerror/onerrorstart.cfm b/core/src/wheels/events/onerror/onerrorstart.cfm new file mode 100644 index 0000000000..8a133a326c --- /dev/null +++ b/core/src/wheels/events/onerror/onerrorstart.cfm @@ -0,0 +1,8 @@ + + + diff --git a/templates/base/src/public/Application.cfc b/templates/base/src/public/Application.cfc index cfe3a9b814..26fc1db243 100644 --- a/templates/base/src/public/Application.cfc +++ b/templates/base/src/public/Application.cfc @@ -265,8 +265,20 @@ component output="false" { } public void function onError( any Exception, string EventName ) { - wirebox = new wirebox.system.ioc.Injector("wheels.Wirebox"); - application.wo = wirebox.getInstance("global"); + try { + wirebox = new wirebox.system.ioc.Injector("wheels.Wirebox"); + application.wo = wirebox.getInstance("global"); + + // Make exception available to the event template + request.wheels = request.wheels ?: {}; + request.wheels.exception = Exception; + request.wheels.eventName = EventName; + + // Run early error event if it exists + application.wo.$include(template = "/wheels/events/onerror/onerrorstart.cfm"); + } catch (any e) { + // Must never break error handling + } // In case the error was caused by a timeout we have to add extra time for error handling. // We have to check if onErrorRequestTimeout exists since errors can be triggered before the application.wheels struct has been created.