Manually thrown error after rescue (or such)

What I'm trying to do it manually shown an error after rescue. Or I'm fine if there is any alternative ways to do this thing

A given example of piece of code

begin some_error_coderescue do_something do_something thrown_original_error_noticeendSays that the error notice would be "Undefined method for nilclass"

But, before error notice is shown, I want to execute some lines of code at first.

Then I manually show the error message

Is there any way?
You can bind the rescued variable to a variable using the following form:

begin my_method rescue => err # do something # do something raise errendWhich is the short form of rescuing a StandardError type and saving the instance in a local variable named err.
Code:
begin   my_method  rescue StandardError => err  # do something  # do something  raise errend
You can then raise 'err' manually, or use your own flow control and avoid raising the error.See also: built in variable $!, which holds the instance for the last exception raised.
Ahay, it works perfectly. Thanks very much 😀

Thread can be closed ~
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/manually-thrown-error-after-rescue-or-such.28503/