lib/byebug/helpers/eval.rb in byebug-6.0.2 vs lib/byebug/helpers/eval.rb in byebug-7.0.0
- old
+ new
@@ -62,11 +62,11 @@
def error_msg(e)
at = e.backtrace
locations = ["#{at.shift}: #{warning_msg(e)}"]
- locations += at.map { |path| "\tfrom #{path}" }
+ locations += at.map { |path| " from #{path}" }
locations.join("\n")
end
def warning_msg(e)
"#{e.class} Exception: #{e.message}"
@@ -78,13 +78,28 @@
# Used to evaluate stuff within Byebug's prompt. Otherwise, any code
# creating new threads won't be properly evaluated because new threads
# will get blocked by byebug's main thread.
#
def allowing_other_threads
+ res = nil
Byebug.unlock
- res = yield
+
+ Thread.new { res = yield }.join
+
Byebug.lock
res
+ end
+
+ def safe_inspect(var)
+ var.inspect
+ rescue
+ safe_to_s(var)
+ end
+
+ def safe_to_s(var)
+ var.to_s
+ rescue
+ '*Error in evaluation*'
end
end
end
end