Skip to content

Commit

Permalink
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/std/exception_spec.cr
Original file line number Diff line number Diff line change
@@ -13,4 +13,9 @@ describe "Exception" do
ex.to_s.should eq("foo? -- bar!")
ex.inspect_with_backtrace.should contain("foo? -- bar!")
end

it "inspects" do
ex = FooError.new("foo?")
ex.inspect.should eq("#<FooError:foo? -- bar!>")
end
end
4 changes: 4 additions & 0 deletions src/exception.cr
Original file line number Diff line number Diff line change
@@ -39,6 +39,10 @@ class Exception
io << message
end

def inspect(io : IO)
io << "#<" << self.class.name << ":" << message << ">"
end

def inspect_with_backtrace
String.build do |io|
inspect_with_backtrace io

0 comments on commit 12ed6df

Please sign in to comment.