Skip to content

Commit 12ed6df

Browse files
asteriteRX14
authored andcommittedSep 20, 2017
Implement Exception#inspect (#5008)
1 parent 0fdf721 commit 12ed6df

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

Diff for: ‎spec/std/exception_spec.cr

+5
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ describe "Exception" do
1313
ex.to_s.should eq("foo? -- bar!")
1414
ex.inspect_with_backtrace.should contain("foo? -- bar!")
1515
end
16+
17+
it "inspects" do
18+
ex = FooError.new("foo?")
19+
ex.inspect.should eq("#<FooError:foo? -- bar!>")
20+
end
1621
end

Diff for: ‎src/exception.cr

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class Exception
3939
io << message
4040
end
4141

42+
def inspect(io : IO)
43+
io << "#<" << self.class.name << ":" << message << ">"
44+
end
45+
4246
def inspect_with_backtrace
4347
String.build do |io|
4448
inspect_with_backtrace io

0 commit comments

Comments
 (0)