# Length of backtrace displayed by ruby

**URL:** <https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543>\
**Category:** Ruby\
**Created:** [April 4, 2006, 5:26pm UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543 "2006-04-04T17:26:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 4, 2006, 5:26pm UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/1 "2006-04-04T17:26:40Z")

</div>

Is there a way to remove the maximum backtrace length displayed by the  
interpreter when an exception terminates the process ? It makes the  
backtrace  
totally useless in situations where it is long _and_ the interesting  
calls  
are in the middle.

Thanks

Sylvain

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 4, 2006, 5:35pm UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/2 "2006-04-04T17:35:56Z")

</div>

Hi,

In message “Re: Length of backtrace displayed by ruby”  
on Wed, 5 Apr 2006 00:25:52 +0900, Sylvain J.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|Is there a way to remove the maximum backtrace length displayed by the  
|interpreter when an exception terminates the process ? It makes the backtrace  
|totally useless in situations where it is long _and_ the interesting calls  
|are in the middle.

Not yet. Do you (or anybody else) have any good API suggestion?

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 4, 2006, 5:48pm UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/3 "2006-04-04T17:48:25Z")

</div>

On Wed, 5 Apr 2006, Yukihiro M. wrote:

> Not yet. Do you (or anybody else) have any good API suggestion?
> 
> ```
> matz.
> 
> ```

Exception.backtrace\_display\_limit = 42

??

-a

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 4, 2006, 11:20pm UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/4 "2006-04-04T23:20:15Z")

</div>

Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Not yet. Do you (or anybody else) have any good API suggestion?
> 
> ```
> matz.
> 
> ```

How about giving a full backtrace with ruby -d?

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 5, 2006, 12:00am UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/5 "2006-04-05T00:00:39Z")

</div>

In message [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid),  
removed\_email\_address@domain.invalid writes

> On Wed, 5 Apr 2006, Yukihiro M. wrote:
> 
> > Not yet. Do you (or anybody else) have any good API suggestion?
> 
> Exception.backtrace\_display\_limit = 42

Exception.setFilter(regularExpression)

where the matching items are removed from the backtrace.

Stephen

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 4, 2006, 7:26pm UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/6 "2006-04-04T19:26:17Z")

</div>

Sylvain J. wrote:

> Is there a way to remove the maximum backtrace length displayed by the  
> interpreter when an exception terminates the process ? It makes the  
> backtrace  
> totally useless in situations where it is long _and_ the interesting  
> calls  
> are in the middle.

IIRC, this only happens when the exception is handled by the top level  
interpreter. If you catch the exception yourself at the top level you  
can print out whatever you want, including the full stack trace.

–  
– Jim W.

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 5, 2006, 7:45am UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/7 "2006-04-05T07:45:34Z")

</div>

> IIRC, this only happens when the exception is handled by the top level  
> interpreter. If you catch the exception yourself at the top level you  
> can print out whatever you want, including the full stack trace.  
> Yes, that’s what I did as a workaround. But you have to do it for every  
> thread and every fork (which in my case is 4 different places)

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 5, 2006, 12:13am UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/8 "2006-04-05T00:13:00Z")

</div>

On Wed, 5 Apr 2006, Stephen K. wrote:

> In message [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid),  
> removed\_email\_address@domain.invalid writes
> 
> > On Wed, 5 Apr 2006, Yukihiro M. wrote:
> > 
> > > Not yet. Do you (or anybody else) have any good API suggestion?
> > 
> > Exception.backtrace\_display\_limit = 42
> 
> Exception.setFilter(regularExpression)
> 
> where the matching items are removed from the backtrace.

what would be matched?

e.to\_s, e.message.to\_s, or e.backtrace.any?{|b|}

regards.

-a

---

<div class="post-metadata">

**Author:** ![Sylvain\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ab992/32.png) [@Sylvain\_J](https://www.ruby-forum.com/u/Sylvain_J)\
**Post date:** [April 5, 2006, 11:41am UTC](https://www.ruby-forum.com/t/length-of-backtrace-displayed-by-ruby/93543/9 "2006-04-05T11:41:54Z")

</div>

In message [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid),  
removed\_email\_address@domain.invalid writes

> > Exception.setFilter(regularExpression)
> > 
> > where the matching items are removed from the backtrace.
> 
> what would be matched?
> 
> e.to\_s, e.message.to\_s, or e.backtrace.any?{|b|}

Class and method name was what I was thinking of.
