# How to handle "System Exceptions" vs "Application Errors" vs

**URL:** <https://www.ruby-forum.com/t/how-to-handle-system-exceptions-vs-application-errors-vs/89592>\
**Category:** Ruby\
**Created:** [March 21, 2007, 12:49pm UTC](https://www.ruby-forum.com/t/how-to-handle-system-exceptions-vs-application-errors-vs/89592 "2007-03-21T12:49:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [March 21, 2007, 12:49pm UTC](https://www.ruby-forum.com/t/how-to-handle-system-exceptions-vs-application-errors-vs/89592/1 "2007-03-21T12:49:34Z")

</div>

Hi all,

Just trying to cement by understanding of how to handle system  
exceptions/application errors/audit events for a Ruby on Rails  
application.  
How do people personally handle the following categories of events.

a) Uncaught exceptions (i.e. bubble up to top)

- Usage: System failure / developer can’t do anything
- Logging: How? Override rails exception framework to  
issue a specific “logger.error” message? Check whether  
a standard Rails “error” will be sent to the log by  
default anyway…
- Alerting: Use of “exception\_notification” plugin.

b) Trapped exceptions (i.e. handle explicitly)

- Usage: Understood application error (not system error)  
/ Developer can offer value add
- Logging: Issue a “logger.error” line
- Alerting: How to hook into “exception\_notification”  
plugin?

c) Application Specific Audit

- Usage: For application specific event (e.g. sale  
has occurred) and want an email alert and log it too.
- Logging: Via use of “logger.info” system (? or need  
custom solution for audit logging?)
- Alerting: How to hook into “exception\_notification”  
plugin from this point?

Any comments / ideas / best practice suggestions would be appreciated.

Cheers  
Greg

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [March 26, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/how-to-handle-system-exceptions-vs-application-errors-vs/89592/2 "2007-03-26T20:12:17Z")

</div>

On Mar 21, 2007, at 6:48 AM, Greg H. wrote:

> Hi all,

Hello.

> Just trying to cement by understanding of how to handle system  
> exceptions/application errors/audit events for a Ruby on Rails  
> application.  
> How do people personally handle the following categories of events.

I’ll add my personal opinions.

> a) Uncaught exceptions (i.e. bubble up to top)

At my company, we use this option:

> - Alerting: Use of “exception\_notification” plugin.

I highly recommend it. In fact, have this in place very early in  
development. I often fix bugs using the information it provides,  
before the client can even email me to report it. 😉

> b) Trapped exceptions (i.e. handle explicitly)
> 
> - Usage: Understood application error (not system error)  
> / Developer can offer value add
> - Logging: Issue a “logger.error” line
> - Alerting: How to hook into “exception\_notification”  
> plugin?

I’m not sure I understand the question here. If you trapped the  
error, you need to deal with it as make sense. That includes  
recording it, if that’s useful information, and giving the user a  
helpful error message.

> c) Application Specific Audit
> 
> - Usage: For application specific event (e.g. sale  
> has occurred) and want an email alert and log it too.
> - Logging: Via use of “logger.info” system (? or need  
> custom solution for audit logging?)
> - Alerting: How to hook into “exception\_notification”  
> plugin from this point?

This sounds like a great candidate for a before\_filter. If you place  
all the controllers you wish to monitor in a hierarchy, you can set  
the filter on the parent controller and add whatever handling is  
appropriate.

Hope this helps.

James Edward G. II
