Skip to content

Commit 223da3c

Browse files
authored
Merge pull request #1895 from wheels-dev/add-error-logging
Add pre logging to wheels
2 parents 5d9a421 + 02449bb commit 223da3c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

public/Application.cfc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,20 @@ component output="false" {
261261
}
262262

263263
public void function onError( any Exception, string EventName ) {
264-
injector = new wheels.Injector("wheels.Bindings");
265-
application.wo = injector.getInstance("global");
264+
try {
265+
injector = new wheels.Injector("wheels.Bindings");
266+
application.wo = injector.getInstance("global");
267+
268+
// Make exception available to the event template
269+
request.wheels = request.wheels ?: {};
270+
request.wheels.exception = Exception;
271+
request.wheels.eventName = EventName;
272+
273+
// Run early error event if it exists
274+
application.wo.$include(template = "/wheels/events/onerror/onerrorstart.cfm");
275+
} catch (any e) {
276+
// Must never break error handling
277+
}
266278

267279
// In case the error was caused by a timeout we have to add extra time for error handling.
268280
// We have to check if onErrorRequestTimeout exists since errors can be triggered before the application.wheels struct has been created.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<cfif structKeyExists(request.wheels, "exception")>
2+
<cflog
3+
file="wheels-errors"
4+
type="error"
5+
text="#request.wheels.exception.message#
6+
#request.wheels.exception.detail#"
7+
>
8+
</cfif>

0 commit comments

Comments
 (0)