Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Fix bug: now fatal errors don't crash the kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Correa Casablanca committed Oct 26, 2017
1 parent b88db3a commit 4d5cb21
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/Actions/ExecuteAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,36 @@ private function getClosure(): callable

$this->shellSoul->writeReturnValue($_);
} catch (BreakException $_e) {
restore_error_handler();
if (ob_get_level() > 0) {
ob_end_clean();
}
$this->shellSoul->writeException($_e);

$this->handleEvalException($_e);
return;
} catch (ThrowUpException $_e) {
restore_error_handler();
if (ob_get_level() > 0) {
ob_end_clean();
}
$this->shellSoul->writeException($_e);

$this->handleEvalException($_e);
throw $_e;
} catch (\Error $_e) {
$this->handleEvalException(new \ErrorException(
$_e->getMessage(),
$_e->getCode(),
1,
$_e->getFile(),
$_e->getLine(),
$_e->getPrevious()
));
} catch (\Exception $_e) {
restore_error_handler();
if (ob_get_level() > 0) {
ob_end_clean();
}
$this->shellSoul->writeException($_e);
$this->handleEvalException($_e);
}

$this->shellSoul->setScopeVariables(get_defined_vars());
};

return $closure;
}

private function handleEvalException(\Exception $_e)
{
restore_error_handler();
if (ob_get_level() > 0) {
ob_end_clean();
}
$this->shellSoul->writeException($_e);
}
}

0 comments on commit 4d5cb21

Please sign in to comment.