|
Revision 1921, 1.1 kB
(checked in by nahi, 1 year ago)
|
|
| Line | |
|---|
| 1 |
# SOAP4R - Nested exception implementation |
|---|
| 2 |
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. |
|---|
| 3 |
|
|---|
| 4 |
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can |
|---|
| 5 |
# redistribute it and/or modify it under the same terms of Ruby's license; |
|---|
| 6 |
# either the dual license version in 2003, or any later version. |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
module SOAP |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
module NestedException |
|---|
| 13 |
attr_reader :cause |
|---|
| 14 |
attr_reader :original_backtraace |
|---|
| 15 |
|
|---|
| 16 |
def initialize(msg = nil, cause = nil) |
|---|
| 17 |
super(msg) |
|---|
| 18 |
@cause = cause |
|---|
| 19 |
@original_backtrace = nil |
|---|
| 20 |
end |
|---|
| 21 |
|
|---|
| 22 |
def set_backtrace(backtrace) |
|---|
| 23 |
if @cause and @cause.respond_to?(:backtrace) |
|---|
| 24 |
@original_backtrace = backtrace |
|---|
| 25 |
=begin |
|---|
| 26 |
# for agressive backtrace abstraction: 'here' only should not be good |
|---|
| 27 |
here = @original_backtrace[0] |
|---|
| 28 |
backtrace = Array[*@cause.backtrace] |
|---|
| 29 |
backtrace[0] = "#{backtrace[0]}: #{@cause} (#{@cause.class})" |
|---|
| 30 |
backtrace.unshift(here) |
|---|
| 31 |
=end |
|---|
| 32 |
# just join the nested backtrace at the tail of backtrace |
|---|
| 33 |
caused = Array[*@cause.backtrace] |
|---|
| 34 |
caused[0] = "#{caused[0]}: #{@cause} (#{@cause.class}) [NESTED]" |
|---|
| 35 |
backtrace += caused |
|---|
| 36 |
end |
|---|
| 37 |
super(backtrace) |
|---|
| 38 |
end |
|---|
| 39 |
end |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
end |
|---|