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
815e0c40
Unverified
Commit
815e0c40
authored
Dec 18, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Dec 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4875 from shuujii/remove-location-info-from-Exception-inspect
Remove location info from `Exception#inspect`
parents
4c1667a5
d2f2f9db
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
59 deletions
+8
-59
include/mruby/class.h
include/mruby/class.h
+1
-0
src/error.c
src/error.c
+4
-57
src/string.c
src/string.c
+0
-1
test/t/exception.rb
test/t/exception.rb
+3
-1
No files found.
include/mruby/class.h
View file @
815e0c40
...
...
@@ -90,6 +90,7 @@ mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
void
mrb_class_name_class
(
mrb_state
*
,
struct
RClass
*
,
struct
RClass
*
,
mrb_sym
);
mrb_bool
mrb_const_name_p
(
mrb_state
*
,
const
char
*
,
mrb_int
);
mrb_value
mrb_class_find_path
(
mrb_state
*
,
struct
RClass
*
);
mrb_value
mrb_mod_to_s
(
mrb_state
*
,
mrb_value
);
void
mrb_gc_mark_mt
(
mrb_state
*
,
struct
RClass
*
);
size_t
mrb_gc_mark_mt_size
(
mrb_state
*
,
struct
RClass
*
);
void
mrb_gc_free_mt
(
mrb_state
*
,
struct
RClass
*
);
...
...
src/error.c
View file @
815e0c40
...
...
@@ -13,7 +13,6 @@
#include <mruby/proc.h>
#include <mruby/string.h>
#include <mruby/variable.h>
#include <mruby/debug.h>
#include <mruby/error.h>
#include <mruby/class.h>
#include <mruby/throw.h>
...
...
@@ -131,34 +130,10 @@ exc_message(mrb_state *mrb, mrb_value exc)
static
mrb_value
exc_inspect
(
mrb_state
*
mrb
,
mrb_value
exc
)
{
mrb_value
str
,
mesg
,
file
,
line
;
mrb_bool
append_mesg
;
const
char
*
cname
;
mesg
=
mrb_attr_get
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"mesg"
));
file
=
mrb_attr_get
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"file"
));
line
=
mrb_attr_get
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"line"
));
append_mesg
=
!
mrb_nil_p
(
mesg
);
if
(
append_mesg
)
{
mesg
=
mrb_obj_as_string
(
mrb
,
mesg
);
append_mesg
=
RSTRING_LEN
(
mesg
)
>
0
;
}
cname
=
mrb_obj_classname
(
mrb
,
exc
);
str
=
mrb_str_new_cstr
(
mrb
,
cname
);
if
(
mrb_string_p
(
file
)
&&
mrb_fixnum_p
(
line
))
{
if
(
append_mesg
)
{
str
=
mrb_format
(
mrb
,
"%v:%v: %v (%v)"
,
file
,
line
,
mesg
,
str
);
}
else
{
str
=
mrb_format
(
mrb
,
"%v:%v: %v"
,
file
,
line
,
str
);
}
}
else
if
(
append_mesg
)
{
str
=
mrb_format
(
mrb
,
"%v: %v"
,
str
,
mesg
);
}
return
str
;
mrb_value
mesg
=
mrb_attr_get
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"mesg"
));
mrb_value
cname
=
mrb_mod_to_s
(
mrb
,
mrb_obj_value
(
mrb_obj_class
(
mrb
,
exc
)));
mesg
=
mrb_obj_as_string
(
mrb
,
mesg
);
return
RSTRING_LEN
(
mesg
)
==
0
?
cname
:
mrb_format
(
mrb
,
"%v (%v)"
,
mesg
,
cname
);
}
void
mrb_keep_backtrace
(
mrb_state
*
mrb
,
mrb_value
exc
);
...
...
@@ -192,33 +167,6 @@ exc_set_backtrace(mrb_state *mrb, mrb_value exc)
return
backtrace
;
}
static
void
exc_debug_info
(
mrb_state
*
mrb
,
struct
RObject
*
exc
)
{
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
const
mrb_code
*
pc
=
ci
->
pc
;
if
(
mrb_obj_iv_defined
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"file"
)))
return
;
while
(
ci
>=
mrb
->
c
->
cibase
)
{
const
mrb_code
*
err
=
ci
->
err
;
if
(
!
err
&&
pc
)
err
=
pc
-
1
;
if
(
err
&&
ci
->
proc
&&
!
MRB_PROC_CFUNC_P
(
ci
->
proc
))
{
mrb_irep
*
irep
=
ci
->
proc
->
body
.
irep
;
int32_t
const
line
=
mrb_debug_get_line
(
mrb
,
irep
,
err
-
irep
->
iseq
);
char
const
*
file
=
mrb_debug_get_filename
(
mrb
,
irep
,
err
-
irep
->
iseq
);
if
(
line
!=
-
1
&&
file
)
{
mrb_obj_iv_set
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"file"
),
mrb_str_new_cstr
(
mrb
,
file
));
mrb_obj_iv_set
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"line"
),
mrb_fixnum_value
(
line
));
return
;
}
}
pc
=
ci
->
pc
;
ci
--
;
}
}
void
mrb_exc_set
(
mrb_state
*
mrb
,
mrb_value
exc
)
{
...
...
@@ -232,7 +180,6 @@ mrb_exc_set(mrb_state *mrb, mrb_value exc)
mrb
->
gc
.
arena_idx
--
;
}
if
(
!
mrb
->
gc
.
out_of_memory
&&
!
mrb_frozen_p
(
mrb
->
exc
))
{
exc_debug_info
(
mrb
,
mrb
->
exc
);
mrb_keep_backtrace
(
mrb
,
exc
);
}
}
...
...
src/string.c
View file @
815e0c40
...
...
@@ -1095,7 +1095,6 @@ mrb_str_equal_m(mrb_state *mrb, mrb_value str1)
return
mrb_bool_value
(
mrb_str_equal
(
mrb
,
str1
,
str2
));
}
/* ---------------------------------- */
mrb_value
mrb_mod_to_s
(
mrb_state
*
mrb
,
mrb_value
klass
);
MRB_API
mrb_value
mrb_str_to_str
(
mrb_state
*
mrb
,
mrb_value
str
)
...
...
test/t/exception.rb
View file @
815e0c40
...
...
@@ -352,8 +352,10 @@ assert('Exception 19') do
assert_equal
[
true
,
true
],
Class4Exception19
.
new
.
a
end
assert
(
'Exception#inspect
without message
'
)
do
assert
(
'Exception#inspect'
)
do
assert_equal
"Exception"
,
Exception
.
new
.
inspect
assert_equal
"Exception"
,
Exception
.
new
(
""
).
inspect
assert_equal
"error! (Exception)"
,
Exception
.
new
(
"error!"
).
inspect
end
assert
(
'Exception#backtrace'
)
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