Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
207577f0
Commit
207577f0
authored
Jul 15, 2015
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mrb_protect() to return the exception raised (with the state of true)
parent
1085167f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
mrbgems/mruby-error/src/exception.c
mrbgems/mruby-error/src/exception.c
+1
-0
mrbgems/mruby-error/test/exception.rb
mrbgems/mruby-error/test/exception.rb
+5
-3
No files found.
mrbgems/mruby-error/src/exception.c
View file @
207577f0
...
...
@@ -17,6 +17,7 @@ mrb_protect(mrb_state *mrb, mrb_func_t body, mrb_value data, mrb_bool *state)
mrb
->
jmp
=
prev_jmp
;
}
MRB_CATCH
(
&
c_jmp
)
{
mrb
->
jmp
=
prev_jmp
;
result
=
mrb_obj_value
(
mrb
->
exc
);
mrb
->
exc
=
NULL
;
if
(
state
)
{
*
state
=
TRUE
;
}
}
MRB_END_EXC
(
&
c_jmp
);
...
...
mrbgems/mruby-error/test/exception.rb
View file @
207577f0
assert
'mrb_protect'
do
# no failure in protect returns [result, false]
assert_equal
[
'test'
,
false
]
do
ExceptionTest
.
mrb_protect
{
'test'
}
end
assert_equal
[
nil
,
true
]
do
ExceptionTest
.
mrb_protect
{
raise
'test'
}
end
# failure in protect returns [exception, true]
result
=
ExceptionTest
.
mrb_protect
{
raise
'test'
}
assert_kind_of
RuntimeError
,
result
[
0
]
assert_true
result
[
1
]
end
assert
'mrb_ensure'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment