# How to get line\_number and file\_name of an exception

**URL:** <https://www.ruby-forum.com/t/how-to-get-line-number-and-file-name-of-an-exception/190368>\
**Category:** Rails\
**Created:** [June 18, 2010, 5:54pm UTC](https://www.ruby-forum.com/t/how-to-get-line-number-and-file-name-of-an-exception/190368 "2010-06-18T17:54:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [June 18, 2010, 5:54pm UTC](https://www.ruby-forum.com/t/how-to-get-line-number-and-file-name-of-an-exception/190368/1 "2010-06-18T17:54:25Z")

</div>

Hi,

My goal is to get the file\_name where an exception happened and its  
line\_number. The way it’s made in Rails is awkward as it gets computed  
in class TemplateError \< ActionViewError which is in the view.

So how to write my own exception handler and use line\_number and  
file\_name which Rails can compute?
