forked from cldwalker/ripl-misc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshort_errors.rb
More file actions
37 lines (27 loc) · 782 Bytes
/
short_errors.rb
File metadata and controls
37 lines (27 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Gem: ripl-short_errors
# By: Jan Lelis
# Description:
# Only show the first backtrace entry when errors are displayed. The complete backtrace can be shown by the _! method.
# Please note:
# Needs to be required before ripl-color_error
require 'ripl'
module Ripl::ShortErrors
VERSION = '0.1.0'
attr_reader :last_error
def format_error(err)
"#{err.class}: #{err.message.chomp}" +
( err.backtrace.first =~ %r|/lib/ripl/shell.rb| ? '' : " [#{err.backtrace.first}]" )
end
def print_eval_error(err)
@last_error = err
super
end
module Commands
def _!
puts Ripl.shell.last_error.backtrace.join("\n ")
end
end
end
Ripl::Shell.send :include, Ripl::ShortErrors
Ripl::Commands.send :include, Ripl::ShortErrors::Commands
# J-_-L