-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Athletic\Common; | ||
use Commando\Command; | ||
use ErrorException; | ||
|
||
/** | ||
* CmdLineErrorHandler | ||
* @package Athletic | ||
*/ | ||
class CmdLineErrorHandler implements ErrorHandlerInterface | ||
{ | ||
/** @var Command $command */ | ||
private $command; | ||
|
||
/** | ||
* @param Command $command | ||
*/ | ||
public function __construct($command) | ||
{ | ||
$this->command = $command; | ||
} | ||
|
||
/* | ||
* {@inheritDoc} | ||
*/ | ||
public function handleException(\Exception $exception) | ||
{ | ||
$this->command->error($exception); | ||
} | ||
|
||
/* | ||
* {@inheritDoc} | ||
*/ | ||
public function handleError($errorLevel, $errorMessage, $errorFile, $errorLine, $errorContext = array()) | ||
{ | ||
// Translate the error to an ErrorException and delegate it to the | ||
// exception handler: | ||
$this->handleException( | ||
new ErrorException($errorMessage, $errorLevel, null, $errorFile, $errorLine) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Athletic\Common; | ||
|
||
/** | ||
* ErrorHandlerInterface | ||
* @package Athletic | ||
*/ | ||
interface ErrorHandlerInterface | ||
{ | ||
/** | ||
* @param int $errorLevel | ||
* @param string $errorMessage | ||
* @param string $errorFile | ||
* @param int $errorLine | ||
* @param array $errorContext | ||
*/ | ||
public function handleError($errorLevel, $errorMessage, $errorFile, $errorLine, $errorContext = array()); | ||
|
||
/** | ||
* @param \Exception $exception | ||
*/ | ||
public function handleException(\Exception $exception); | ||
} |