Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
romaninsh committed Jul 5, 2016
2 parents 3dc69f5 + 7346f34 commit b18a992
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.3

* Minor cleanups, exception will now show previous exception

## 1.0.2

* Added FactoryTrait
* FactoryTrait has normalizeClassName method

## 1.0.1

Expand Down
3 changes: 2 additions & 1 deletion src/ContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function add($obj, $args = [])
{
if (isset($this->_factoryTrait)) {
// Factory allows us to pass string-type objects
$obj = $this->factory($obj, $args);
$obj = $this->factory($this->normalizeClassName($obj), $args);
}
$obj = $this->_add_Container($obj, $args);

Expand Down Expand Up @@ -196,6 +196,7 @@ function getElement($short_name) {
if (!isset($this->elements[$short_name])) {
throw new Exception([
'Child element not found',
'parent'=>$this,
'element'=>$short_name
]);
}
Expand Down
15 changes: 10 additions & 5 deletions src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ public function getColorfulText()

foreach($this->getTrace() as $i=>$call) {
if (!isset($call['file'])) {
break;
}

if (
$call['file'] = '';
} elseif (
$in_atk &&
strpos($call['file'], '/data/src/') === false &&
strpos($call['file'], '/core/src/') === false &&
Expand All @@ -80,7 +78,7 @@ public function getColorfulText()
$line = str_pad($call['line'], 4, ' ', STR_PAD_LEFT);

$output .= "\n\033[0;34m".$file."\033[0m";
$output .= ":\033[0;31m".$call['line']."\033[0m";
$output .= ":\033[0;31m".$line."\033[0m";

if (isset($call['object'])) {
$name = (!isset($call['object']->name)) ? get_class($call['object']) : $call['object']->name;
Expand Down Expand Up @@ -114,9 +112,16 @@ public function getColorfulText()

}

if ($p= $this->getPrevious()) {
$output .= "\n\033[0mCaused by Previous Exception:\n";
$output .= "\033[1;31m".get_class($p).": ".$p->getMessage()."\033[0;31m".
($p->getCode() ? ' [code: '.$p->getCode().']' : '');
}

// next print params

$output .= "\n\033[1;31m--------------------------------------------------------\n";

return $output."\033[0m";
}

Expand Down

0 comments on commit b18a992

Please sign in to comment.