Add some debugging

This commit is contained in:
Alex Kotov 2023-09-30 01:33:59 +04:00
parent 19beb1901a
commit 3548d5995a
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -12,7 +12,7 @@ $stdout.sync = true
def parse_command(line) def parse_command(line)
line = String(line).chomp line = String(line).chomp
command = line[0...line.index(' ')].freeze command = line[0...line.index(' ')].upcase.freeze
rest = line[command.length..].strip.freeze rest = line[command.length..].strip.freeze
[command, rest].freeze [command, rest].freeze
end end
@ -31,6 +31,7 @@ workdir = File.expand_path(workdir).freeze
config = Referator::Config.new workdir config = Referator::Config.new workdir
footnotes = Referator::Footnotes.new config footnotes = Referator::Footnotes.new config
stacktrace = nil
while (line = $stdin.gets) while (line = $stdin.gets)
begin begin
@ -39,6 +40,11 @@ while (line = $stdin.gets)
when 'EXIT' when 'EXIT'
success success
exit exit
when 'PING'
success :pong
when 'STACKTRACE'
success stacktrace
stacktrace = nil
when 'REGISTER_FORMAT' when 'REGISTER_FORMAT'
data = JSON.parse rest data = JSON.parse rest
config.formats.register( config.formats.register(
@ -76,6 +82,7 @@ while (line = $stdin.gets)
raise 'Invalid command' raise 'Invalid command'
end end
rescue => e rescue => e
stacktrace = e.backtrace.map(&:freeze).freeze
failure e.detailed_message failure e.detailed_message
end end
end end