Skip to content

Commit

Permalink
add info to --debug
Browse files Browse the repository at this point in the history
show pipelines and php version information above the error traces.
  • Loading branch information
ktomk committed Jul 23, 2020
1 parent 6f5b90d commit 8945722
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [unreleased]
### Added
- version info to `--debug` above the stacktrace/s (thanks [Andreas Sundqvist])
[Andreas Sundqvist]: https://github.com/sunkan

## [0.0.46] - 2020-07-10
### Fixed
Expand Down
12 changes: 12 additions & 0 deletions src/Utility/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ private function isUnexpectedException(Exception $e)
*/
private function debugException(Exception $e)
{
$this->debugInfoOfPipelinesItself();

for (; $e; $e = $e->getPrevious()) {
$this->error('--------');
$this->error(sprintf('class....: %s', get_class($e)));
Expand All @@ -163,6 +165,16 @@ private function debugException(Exception $e)
$this->error('--------');
}

private function debugInfoOfPipelinesItself()
{
$this->error(sprintf(
'pipelines: version %s w/ php %s (libyaml: %s)',
Version::resolve(App::VERSION),
PHP_VERSION,
\phpversion('yaml') ?: 'n/a'
));
}

/**
* @param string $message
*
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Utility/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testCreation()
public function testMainExceptionHandlingArgsException()
{
$app = new App(new Streams(null, null, 'php://output'));
$this->expectOutputRegex('{^pipelines: option --prefix requires an argument\n--------\nclass....:}');
$this->expectOutputRegex('{^pipelines: option --prefix requires an argument\npipelines: version .*\n--------\nclass....:}');
$actual = $app->main(array('cmd', '--debug', '--prefix'));
self::assertNotSame(0, $actual);
}
Expand Down

0 comments on commit 8945722

Please sign in to comment.