Skip to content

Commit

Permalink
Merge pull request #1679 from herwinw/raise_backtrace
Browse files Browse the repository at this point in the history
Support backtrace argument in Kernel.raise
  • Loading branch information
herwinw committed Jan 8, 2024
2 parents 3b30d57 + c16544d commit 9964002
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions spec/shared/kernel/raise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,8 @@ def initialize
end

it "allows Exception, message, and backtrace parameters" do
NATFIXME 'backtrace parameter', exception: SpecFailedException do
-> do
@object.raise(ArgumentError, "message", caller)
end.should raise_error(ArgumentError, "message")
end
-> do
@object.raise(ArgumentError, "message", caller)
end.should raise_error(ArgumentError, "message")
end
end
6 changes: 3 additions & 3 deletions src/exception_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ ExceptionObject *ExceptionObject::create_for_raise(Env *env, Args args, Exceptio
else
env->ensure_no_extra_keywords(kwargs);

if (backtrace)
env->raise("StandardError", "NATFIXME: Unsupported backtrace argument to exception");

if (!klass && !message && cause)
env->raise("ArgumentError", "only cause is given with no arguments");

Expand Down Expand Up @@ -60,6 +57,9 @@ ExceptionObject *ExceptionObject::create_for_raise(Env *env, Args args, Exceptio
exception->set_cause(cause->as_exception());
}

if (backtrace)
exception->set_backtrace(env, backtrace);

return exception;
}

Expand Down

0 comments on commit 9964002

Please sign in to comment.