Skip to content

Instantly share code, notes, and snippets.

@mishak87
Created November 27, 2013 12:26
Show Gist options
  • Save mishak87/7674859 to your computer and use it in GitHub Desktop.
Save mishak87/7674859 to your computer and use it in GitHub Desktop.
getsentry.com + nette
Replace <secret> and <id> with your API key DSN
<?php
// ... autoload and stuff
/**
* Really stupid handler that takes first argument that is instance of an exception
*/
Nette\Diagnostics\Debugger::$onFatalError[] = $errorHandler = function () {
static $client = NULL;
$e = NULL;
foreach (func_get_args() as $arg) {
if ($arg instanceof Exception) {
$e = $arg;
break;
}
}
if ($e !== NULL) {
if ($client === NULL) {
$client = new Raven_Client('https://<secret>@app.getsentry.com/<id>');
}
$client->captureException($e);
}
};
// ... $configurator->enableDebugger(__DIR__ . '/../log'); ...
// ... $container = $configurator->createContainer();
$container->application->onError[] = $errorHandler;
// ... soldier on ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment