Update rescue.rb

This commit is contained in:
0x1eef 2024-05-23 22:35:51 -03:00
parent 4f162796b0
commit b0d6c19ab4

View file

@ -2,8 +2,8 @@
module Twenty::Command::Hook module Twenty::Command::Hook
module Rescue module Rescue
FRAME_MAX = 15 FRAMEMAX = 15
INDENT_BY = 2 INDENTBY = 2
def run(...) def run(...)
super(...) super(...)
@ -12,7 +12,7 @@ module Twenty::Command::Hook
$stderr.print "\n", $stderr.print "\n",
" ", Paint[" Exception ", :white, :red, :bold], "\n", " ", Paint[" Exception ", :white, :red, :bold], "\n",
" ", Paint[ex.class.to_s, :bold], "\n", " ", Paint[ex.class.to_s, :bold], "\n",
ex.message.each_line.map { [" " * INDENT_BY, _1] }.join, ex.message.each_line.map { [" " * INDENTBY, _1] }.join,
"\n\n", "\n\n",
" ", Paint[" Backtrace ", :white, :blue, :bold], "\n", " ", Paint[" Backtrace ", :white, :blue, :bold], "\n",
format_backtrace(ex.backtrace), "\n", format_backtrace(ex.backtrace), "\n",
@ -22,8 +22,8 @@ module Twenty::Command::Hook
private private
def format_backtrace(backtrace) def format_backtrace(backtrace)
backtrace[0..FRAME_MAX - 1].map do backtrace[0..FRAMEMAX - 1].map do
[" " * INDENT_BY, _1.gsub(Dir.getwd, "")].join [" " * INDENTBY, _1.gsub(Dir.getwd, "")].join
end.join("\n") end.join("\n")
end end
end end