mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Fix try
: Add set_last_error()
to prepare_error_handler()
for IR eval (#13838)
# Description Fixes a bug with `set_last_error()` introduced by @IanManske not being called during the jump to an error handler in IR eval. Without this, `$env.LAST_EXIT_CODE` wasn't getting set in the `catch` block for an external. # Tests + Formatting Added a `tests/eval` test to cover this in both IR and non-IR eval
This commit is contained in:
@ -246,6 +246,8 @@ fn prepare_error_handler(
|
||||
) {
|
||||
if let Some(reg_id) = error_handler.error_register {
|
||||
if let Some(error) = error {
|
||||
// Stack state has to be updated for stuff like LAST_EXIT_CODE
|
||||
ctx.stack.set_last_error(&error.item);
|
||||
// Create the error value and put it in the register
|
||||
ctx.put_reg(
|
||||
reg_id,
|
||||
|
Reference in New Issue
Block a user