summaryrefslogtreecommitdiffhomepage
path: root/src/error.c
AgeCommit message (Collapse)Author
2020-01-01Rename `mrb_num_args_error` to `mrb_argnum_error`; ref #4863Yukihiro "Matz" Matsumoto
2020-01-01Merge pull request #4863 from ↵Yukihiro "Matz" Matsumoto
shuujii/add-mrb_num_args_error-for-wrong-number-of-arguments-error Add `mrb_num_args_error()` for "wrong number of arguments" error
2019-12-20Fix potentially crash in `%n` of `mrb_vformat()` with 64-bit `int`KOBAYASHI Shuji
If `mrb_sym` is smaller than `int`, it is promoted to `int`.
2019-12-18Simplify `print_backtrace()`KOBAYASHI Shuji
2019-12-18Merge pull request #4875 from ↵Yukihiro "Matz" Matsumoto
shuujii/remove-location-info-from-Exception-inspect Remove location info from `Exception#inspect`
2019-12-17Refine output of `mrb_print_error()`KOBAYASHI Shuji
The following improvements are made according to Ruby's behavior: - Match location number to index. - Remove duplicate most recent call output. - Fix that first call is not output when array (unpacked) backtrace. ### Example ```ruby def a; raise "error!" end def b; a end begin b rescue => e e.backtrace if ARGV[0] == "unpack" # unpack backtrace raise e end ``` #### Before this patch: ``` $ bin/mruby example.rb unpack trace (most recent call last): [0] example.rb:2:in b [1] example.rb:1:in a example.rb:1: error! (RuntimeError) ``` #### After this patch: ``` $ bin/mruby example.rb unpack trace (most recent call last): [2] example.rb:4 [1] example.rb:2:in b example.rb:1:in a: error! (RuntimeError) ```
2019-12-14Remove location info from `Exception#inspect`KOBAYASHI Shuji
Because location info (file name and line number) is kept in the backtrace, it should not be kept in the result of `inspect` (and the exception object itself), I think. ### Example ```ruby # example.rb begin raise "err" rescue => e p e end ``` #### Before this patch: ``` $ bin/mruby example.rb example.rb:2: err (RuntimeError) ``` #### After this patch: ``` $ bin/mruby example.rb err (RuntimeError) ```
2019-12-12Add `mrb_num_args_error()` for "wrong number of arguments" errorKOBAYASHI Shuji
To unify the style of messages.
2019-10-24Fix argument specs to `Exception`KOBAYASHI Shuji
2019-09-29Allow rethrowing `MRB_TT_BREAK`dearblue
2019-09-24`Exception#initialize` should not allow two or more argumentsKOBAYASHI Shuji
2019-09-14Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.Yukihiro "Matz" Matsumoto
2019-09-08Fix `mrb_vformat()` crashes with `MRB_INT16`dearblue
If `MRB_INT16` is specified, the variable length argument `mrb_int` is converted to `int`.
2019-08-18Prohibit changes to iseq in principledearblue
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-08-03Change second argument to `%l` of `mrb_vformat()` to `size_t` from `mrb_int`KOBAYASHI Shuji
- `size_t` is more commonly used. - `len` argument of `mrb_str_new()` is `size_t`. NOTE: The test for `%l` is temporarily disabled because adding a new type to `mrbgems/mruby-test/vformat.c` causes an error (memory error?) on Visual Studio 2017 in AppVeyor.
2019-08-03Fix `mrb_vformat("%f")` with `MRB_USE_FLOAT`KOBAYASHI Shuji
It potentially not work when `mrb_float` is `float` because `float` variable in variable length arguments is promoted to `double`. Also I fixed build with `MRB_WITHOUT_FLOAT`.
2019-08-02Change the `mrb_vformat` specifier `%d` for `int`KOBAYASHI Shuji
It potentially breaks, for example, in the case of `mrb_int` is 64-bit and more smaller type is passed by `%d`. In fact, the problem could become apparent when I used `%d` to `backtrace_location::lineno` in `src/backtrace.c:mrb_unpack_backtrace()` on AppVeyor. Therefore, change `%d` for `int` (not `mrb_int`) so that it can be used mostly without casting.
2019-08-01Add new specifiers/modifiers to format string of `mrb_vfromat()`KOBAYASHI Shuji
Format sequence syntax: %[modifier]specifier Modifiers: ----------+------------------------------------------------------------ Modifier | Meaning ----------+------------------------------------------------------------ ! | Convert to string by corresponding `inspect` instead of | corresponding `to_s`. ----------+------------------------------------------------------------ Specifiers: ----------+----------------+-------------------------------------------- Specifier | Argument Type | Note ----------+----------------+-------------------------------------------- c | char | d,i | mrb_int | f | mrb_float | l | char*, mrb_int | Arguments are string and length. n | mrb_sym | s | char* | Argument is NUL terminated string. t | mrb_value | Convert to type (class) of object. v,S | mrb_value | C | struct RClass* | T | mrb_value | Convert to real type (class) of object. Y | mrb_value | Same as `!v` if argument is `true`, `false` | | or `nil`, otherwise same as `T`. % | - | Convert to percent sign itself (no argument | | taken). ----------+----------------+-------------------------------------------- This change will increase the binary size, but replacing all format strings with new specifiers/modifiers will decrease the size because it reduces inline expansion of `mrb_obj_value()`, etc. at the caller.
2019-04-09Extract frozen checking to functionKOBAYASHI Shuji
2019-04-01Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342Yukihiro "Matz" Matsumoto
The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them.
2019-02-27Add newline to warning by `mrb_warn()`KOBAYASHI Shuji
2018-11-19Use type checking `mrb_to_str` instead of converting `mrb_str_to_str`.Yukihiro "Matz" Matsumoto
2018-05-23Check if the exception is frozen; fix #4025Yukihiro "Matz" Matsumoto
`exc_debug_info()` and `mrb_keep_backtrace()` raise `FrozenError` if the exception is frozen and lead to infinite loop.
2018-01-25Check `arena_idx` before accessing; fix #3934Yukihiro "Matz" Matsumoto
2017-12-04Remove temporary objects from GC arena in `mrb_vformat()'; #3863Yukihiro "Matz" Matsumoto
2017-12-04Pop exception objects from the bottom of GC arena; fix #3863Yukihiro "Matz" Matsumoto
2017-11-02don't overwrite backtrace info.Tomoyuki Sahara
2017-09-27fix: src\kernel.c(874): warning C4244: 'function': conversion from 'mrb_int' ↵Tomasz Dąbrowski
to 'int', possible loss of data
2017-09-27fix: src\error.c(76): warning C4244: '=': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'int', possible loss of data
2017-08-12Reduce integer type mismatch warnings in VC.Yukihiro "Matz" Matsumoto
2017-08-11Should not call `to_str` in `mrb_vformat`; fix #3773Yukihiro "Matz" Matsumoto
2017-07-12Use "$!" specifier of `mrb_get_args`.Yukihiro "Matz" Matsumoto
2017-07-05Put a space between error position and error message.Yukihiro "Matz" Matsumoto
For readability's sake.
2017-06-14The out-of-memory error should not be an instance of RuntimeError.Yukihiro "Matz" Matsumoto
And arena-overflow error as well. They should not be caught by `rescue` by default.
2017-05-31Restore MRB_API function `mrb_exc_backtrace(mrb, exc)`; ref 9644ad5Yukihiro "Matz" Matsumoto
2017-05-23Simplify backtrace mechanism; fix #3633 #3634 #3644Yukihiro "Matz" Matsumoto
Instead of preserving a backtrace in `mrb_state`, `mrb_exc_set` keeps packed backtrace in an exception object. `#backtrace` unpacks it to an array of strings.
2017-05-23Support the case when the backtrace is not an array.Yukihiro "Matz" Matsumoto
2017-05-23Update comments regarding Exception#to_strYukihiro "Matz" Matsumoto
2017-04-25Avoid use of `snprintf()` when DISABLE_STDIO is set; fix #3632Yukihiro "Matz" Matsumoto
ref #3492 #3515 #3517
2017-04-18Call exc_debug_info() in mrb_exc_set(); ref #3610Yukihiro "Matz" Matsumoto
Otherwise line number information is lacked from exceptions raised in VM, e.g. "super called outside of method".
2017-03-19Fixed some compiler errors regarding PRId.Yukihiro "Matz" Matsumoto
2017-03-19Use MRB_PRId instead of "%d"; fix #3515Yukihiro "Matz" Matsumoto
2017-03-19Remove cname duplication from exc_inspect().Yukihiro "Matz" Matsumoto
2017-03-19Avoid possible infinite recursion in mrb_print_error(); ref #3517Yukihiro "Matz" Matsumoto
2017-03-18Save/restore GC arena index to avoid arena overflow error.Yukihiro "Matz" Matsumoto
2017-03-18Avoid mrb_check_string_type() in raising exception; fix #3506Yukihiro "Matz" Matsumoto
The change may reduce flexibility, but I believe no one wants that level of flexibility here.
2017-03-02Create NoMethodError instance using `mrb_obj_new()`.Yukihiro "Matz" Matsumoto
2017-02-15Do not funcall() Exception#set_backtrace from runtime.Yukihiro "Matz" Matsumoto
This change reduce flexibility but makes mruby simpler and faster.
2017-02-15Preallocate SystemStackError; ref #3421Yukihiro "Matz" Matsumoto