# What is hijacking exceptions?

**URL:** <https://www.ruby-forum.com/t/what-is-hijacking-exceptions/90857>\
**Category:** Rails\
**Created:** [April 2, 2007, 1:08pm UTC](https://www.ruby-forum.com/t/what-is-hijacking-exceptions/90857 "2007-04-02T13:08:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluetrust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@bluetrust](https://www.ruby-forum.com/u/bluetrust)\
**Post date:** [April 2, 2007, 1:08pm UTC](https://www.ruby-forum.com/t/what-is-hijacking-exceptions/90857/1 "2007-04-02T13:08:57Z")

</div>

I really would appreciate someone who can help me this.

Even if I wrap my whole view in a begin rescue block, I am still  
having it fail silently with no exception logging & no output when  
there is an error in code called in the view.

The farthest I’ve got is to discover than in rescue.rb, exceptions  
never trickle back up to the rescue in perform\_action\_with\_rescue:

in rescue.rb,

def perform\_action\_with\_rescue #:nodoc:  
perform\_action\_without\_rescue  
RAILS\_DEFAULT\_LOGGER.debug("rescue.rb - A: ")  
rescue Exception =\> exception # errors from action performed  
RAILS\_DEFAULT\_LOGGER.debug("rescue.rb - B: ")

when the code called by the template has an exception, execution  
never returns to either point A or point B

There’s about a dozen or more levels of filters, caching,  
benchmarking etc. after that point that I haven’t traced through yet.  
Does anyone have any idea what/why could be swallowing exceptions?

Michael J.

---

<div class="post-metadata">

**Author:** ![bluetrust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@bluetrust](https://www.ruby-forum.com/u/bluetrust)\
**Post date:** [April 2, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/what-is-hijacking-exceptions/90857/2 "2007-04-02T16:30:45Z")

</div>

Michael J. wrote:

> There’s about a dozen or more levels of filters, caching,  
> benchmarking etc. after that point that I haven’t traced through yet.  
> Does anyone have any idea what/why could be swallowing exceptions?

First, I am assuming you are using the development configuration as  
rails handles failures differently (and logs differently) in other  
configurations.

Secondly, if you never see the exception. How do you know one is being  
raised?

Third, if you are sure that an exception is raised. Does the  
RAILS\_DEFAULT\_LOGGER exist or did you change it in your configuration?

Fourth, if the logger is logging, is the logger set to a higher priority  
than debug? If you are in a different development environment, the  
logger may have a higher priority than debug such as: error in which  
case you won’t see the errors above…

Lastly, If it does exist, does it have permission to write to the file  
that it’s writing to under the account that rails is running under?

hope this helps…

ilan

---

<div class="post-metadata">

**Author:** ![bluetrust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@bluetrust](https://www.ruby-forum.com/u/bluetrust)\
**Post date:** [April 2, 2007, 6:11pm UTC](https://www.ruby-forum.com/t/what-is-hijacking-exceptions/90857/3 "2007-04-02T18:11:50Z")

</div>

> First, I am assuming you are using the development configuration as  
> rails handles failures differently (and logs differently) in other  
> configurations.

yes, of course

> Secondly, if you never see the exception. How do you know one is  
> being  
> raised?

sometimes if I wrap the template in a begin/rescue, I can see the  
exceptions. But sometimes they are lost when I do that too.  
Anyway, if there was no exception, it would serve the view. What I’m  
talking about is when I’m developing, and I write some code. If the  
code has an error in it, all I get is “network lost connection” from  
the browser, and nothing in the log.

> Third, if you are sure that an exception is raised. Does the  
> RAILS\_DEFAULT\_LOGGER exist or did you change it in your configuration

RAILS\_DEFAULT\_LOGGER is fine. That’s how I currently resort to  
finding where my error is, by sticking in log statements until one  
doesn’t get printed

> 

> Fourth, if the logger is logging, is the logger set to a higher  
> priority  
> than debug? If you are in a different development environment, the  
> logger may have a higher priority than debug such as: error in which  
> case you won’t see the errors above…  
> No, the problem has nothing to do with that. I use logger.debug all  
> the time.  
> Lastly, If it does exist, does it have permission to write to the file  
> that it’s writing to under the account that rails is running under?  
> The development log is ok. Normal logging works fine. This is a case  
> of something capturing and not passing along exceptions to where they  
> should bubble.

It’s probably a bug in some plugin that I installed that adds some  
filter to the dispatch chain that has a rescue in it that doesn’t re-  
throw, and I’m going to have to wade through the layers of dispatch  
code after “perform\_action\_with\_rescue” to find it. I was just hoping  
someone might know off the top of their head, because the dispatch  
code is somewhat abstracted and tough to trace through.

> hope this helps…
> 
> ilan

THanks,  
Michael

---

<div class="post-metadata">

**Author:** ![bluetrust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@bluetrust](https://www.ruby-forum.com/u/bluetrust)\
**Post date:** [April 3, 2007, 5:13pm UTC](https://www.ruby-forum.com/t/what-is-hijacking-exceptions/90857/4 "2007-04-03T17:13:31Z")

</div>

Ok, I figured out that it is Globalize.

I don’t understand yet after a first look at the code how it is  
killing the exception handling, but if I comment out the contents of  
the Globalize plugin’s ActionView extensions, exceptions get reported  
in the production.log (although still not to the browser, haven’t  
figured that part out yet)

I don’t really understand by looking at the globalize code how it is  
preventing exceptions from bubbling back, though.

Michael J.
