aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authorSteven Harman <steven@harmanly.com>2019-08-14 10:35:47 -0400
committerAaron Patterson <tenderlove@ruby-lang.org>2019-08-14 10:35:47 -0400
commit7da40d74e12cee72b96554a2d201965f1c7dedd7 (patch)
treece4296dd2fbf3fa4940896720c77c323a66b3fb4 /error.c
parent48e9155e659f332a82234831e1aa0d93a8b83a2a (diff)
downloadruby-7da40d74e12cee72b96554a2d201965f1c7dedd7.tar.gz
backtrace and backtrace_locations can be nil (#2358)
Exception#backtrace and Exception#backtrace_locations can both be nil if not set. The former can be set via `Exception#set_backtrace`, but the later is only ever set at runtime via `setup_backtrace`.
Diffstat (limited to 'error.c')
-rw-r--r--error.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/error.c b/error.c
index 90a9c44939..786c525be8 100644
--- a/error.c
+++ b/error.c
@@ -1114,7 +1114,7 @@ exc_inspect(VALUE exc)
/*
* call-seq:
- * exception.backtrace -> array
+ * exception.backtrace -> array or nil
*
* Returns any backtrace associated with the exception. The backtrace
* is an array of strings, each containing either ``filename:lineNo: in
@@ -1139,6 +1139,12 @@ exc_inspect(VALUE exc)
* prog.rb:2:in `a'
* prog.rb:6:in `b'
* prog.rb:10
+ *
+ * In the case no backtrace has been set, +nil+ is returned
+ *
+ * ex = StandardError.new
+ * ex.backtrace
+ * #=> nil
*/
static VALUE
@@ -1179,13 +1185,13 @@ rb_get_backtrace(VALUE exc)
/*
* call-seq:
- * exception.backtrace_locations -> array
+ * exception.backtrace_locations -> array or nil
*
* Returns any backtrace associated with the exception. This method is
* similar to Exception#backtrace, but the backtrace is an array of
* Thread::Backtrace::Location.
*
- * Now, this method is not affected by Exception#set_backtrace().
+ * This method is not affected by Exception#set_backtrace().
*/
static VALUE
exc_backtrace_locations(VALUE exc)