PHP code example of pioniro / contextable-exception
1. Go to this page and download the library: Download pioniro/contextable-exception library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pioniro / contextable-exception example snippets
function badFunction($id)
{
throw new \Exception(sprintf('bad Id: %d', $id));
}
use Pioniro\ContextableException\ContextableInterface;
use Pioniro\ContextableException\ContextableTrait;
class MyException extends \Exception implements ContextableInterface {
use ContextableTrait;
}
function badFunction($id)
{
throw (new MyException('bad Id'))->addContext(['id' => $id]);
}