Skip to content

Commit 27e7f2a

Browse files
committed
Define error handler behavior
Resolves #95.
1 parent 0581b38 commit 27e7f2a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Loop.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,14 @@ public static function getState($key)
342342
/**
343343
* Set a callback to be executed when an error occurs.
344344
*
345+
* The callback receives the error as the first and only parameter. The return value of the callback gets ignored.
346+
* If it can't handle the error, it MUST throw the error. Errors thrown by the callback or during its invocation
347+
* MUST be thrown into the `run` loop and stop the driver.
348+
*
345349
* Subsequent calls to this method will overwrite the previous handler.
346350
*
347-
* @param callable(\Throwable|\Exception $error)|null $callback The callback to execute; null will clear the current
348-
* handler.
351+
* @param callable(\Throwable|\Exception $error)|null $callback The callback to execute. `null` will clear the
352+
* current handler.
349353
*
350354
* @return void
351355
*/

src/Loop/Driver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ final public function getState($key)
227227
/**
228228
* Set a callback to be executed when an error occurs.
229229
*
230+
* The callback receives the error as the first and only parameter. The return value of the callback gets ignored.
231+
* If it can't handle the error, it MUST throw the error. Errors thrown by the callback or during its invocation
232+
* MUST be thrown into the `run` loop and stop the driver.
233+
*
230234
* Subsequent calls to this method will overwrite the previous handler.
231235
*
232236
* @param callable(\Throwable|\Exception $error)|null $callback The callback to execute. `null` will clear the

0 commit comments

Comments
 (0)