Skip to content

Commit

Permalink
Improved method to truncate long backtraces.
Browse files Browse the repository at this point in the history
  • Loading branch information
badBlackShark committed May 10, 2018
1 parent 661062c commit a6eda45
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/misc_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ module MiscCommands
embed.title = 'Evaluation of code.'
event.channel.send_embed('', embed)
rescue Exception => e
backtrace = e.backtrace.join("\n")
'An error occured while evaluating your code: '\
"```#{e}``` at ```#{e.backtrace.join("\n")[0..1800].gsub(/\s\w+\s*$/, '...')}```"
"```#{e}``` at ```#{backtrace.length > 1800 ? backtrace[0, backtrace.rindex(/\n/,1800)].rstrip << "\n..." : backtrace}```"
end
end
end

0 comments on commit a6eda45

Please sign in to comment.