mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Cleanup
This commit is contained in:
parent
877831a98b
commit
0a7909fb7a
1 changed files with 33 additions and 11 deletions
|
@ -24,19 +24,15 @@ module Spectator::Formatting::Components
|
||||||
# Display error information.
|
# Display error information.
|
||||||
private def content(io)
|
private def content(io)
|
||||||
# Fetch the error and message.
|
# Fetch the error and message.
|
||||||
# If there's no message
|
|
||||||
error = @result.error
|
error = @result.error
|
||||||
lines = error.message.try(&.lines) || {"<blank>".colorize(:purple)}
|
lines = error.message.try(&.lines)
|
||||||
|
|
||||||
# Display the error type and first line of the message.
|
# Write the error and message if available.
|
||||||
line(io) do
|
case
|
||||||
io << "#{error.class}: ".colorize(:red)
|
when lines.nil? then write_error_class(io, error)
|
||||||
io << lines.first
|
when lines.size == 1 then write_error_message(io, error, lines.first)
|
||||||
end
|
when lines.size > 1 then write_multiline_error_message(io, error, lines)
|
||||||
|
else write_error_class(io, error)
|
||||||
# Display additional lines after the first if there's any.
|
|
||||||
lines.skip(1).each do |entry|
|
|
||||||
line(io) { io << entry }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Display the backtrace if it's available.
|
# Display the backtrace if it's available.
|
||||||
|
@ -45,6 +41,32 @@ module Spectator::Formatting::Components
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Display just the error type.
|
||||||
|
private def write_error_class(io, error)
|
||||||
|
line(io) do
|
||||||
|
io << error.class.colorize(:red)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Display the error type and first line of the message.
|
||||||
|
private def write_error_message(io, error, message)
|
||||||
|
line(io) do
|
||||||
|
io << "#{error.class}: ".colorize(:red)
|
||||||
|
io << message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Display the error type and its multi-line message.
|
||||||
|
private def write_multiline_error_message(io, error, lines)
|
||||||
|
# Use the normal formatting for the first line.
|
||||||
|
write_error_message(io, error, lines.first)
|
||||||
|
|
||||||
|
# Display additional lines after the first.
|
||||||
|
lines.skip(1).each do |entry|
|
||||||
|
line(io) { io << entry }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Writes the backtrace entries to the output.
|
# Writes the backtrace entries to the output.
|
||||||
private def write_backtrace(io, backtrace)
|
private def write_backtrace(io, backtrace)
|
||||||
backtrace.each do |entry|
|
backtrace.each do |entry|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue