-
Notifications
You must be signed in to change notification settings - Fork 48
How can I Integrate RequestReduce with my error logging?
RequestReduce scans your original CSS and builds a master image file with sprites in a background thread. It is very possible for errors to occur during this operation due to network issues getting to the css and image files or by various http errors raised by attempting to access these resources. There could also be file or database (if you are using the sqlserverstore) permissions due to an environment misconfiguration. RequestReduce is also very new and I have not yet engaged my army of under aged Laosian youth in testing all functionality. However there is a solid base of automated unit and integration tests. Because this processing occurs in the background, errors raised will be swallowed and details will not be bubbled to your app. If you have an error logging solution in place such as Elmah, RequestReduce exposes a way to feed it with any errors that occur.
The best place to hook this up would be in the Application_Start method of your global.asax. The RequestReduceModule class has a static CaptureError method which takes a generic Action delegate with an Exception parameter. Keep in mind that the errors raised by the background thread have no HttpContext. So our delegate should not try to access HttpContext.Current.
Here is an example of how to have RequestReduce errors fed to an Elmah log:
RequestReduceModule.CaptureError(x => ErrorLog.GetDefault(null).Log(new Error(x)));