You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set a custom exception handler as callback. The callback receives exception & exit code. The callback may rethrow exception or may exit the program or just log exception and do nothing else.
259
+
260
+
```php
261
+
$app = new Ahc\Cli\Application('App', 'v0.0.1');
262
+
$app->add(...);
263
+
$app->onException(function (Throwable $e, int $exitCode) {
264
+
// send to sentry
265
+
// write to logs
266
+
267
+
// optionally, exit with exit code:
268
+
exit($exitCode);
269
+
270
+
// or optionally rethrow, a rethrown exception is propagated to top layer caller.
271
+
throw $e;
272
+
})->handle($argv);
273
+
```
274
+
255
275
#### App help
256
276
257
277
It can be triggered manually with `$app->showHelp()` or automatic when `-h` or `--help` option is passed to `$app->parse()`.
0 commit comments