Skip to content

Commit

Permalink
Defines template message for several exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Edmond committed Dec 26, 2013
1 parent e0e1650 commit 603de4c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
12 changes: 4 additions & 8 deletions source/CallableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@
namespace Exceptions;

/**
* Rais if the expression is not callable.
* Raise if the expression is not callable.
* (Usually when using function is_callable)
*/
class CallableException extends LoggableException
{
protected $template = 'Expression {expression} is not callable';

/**
* Expression is not callable!
*
* @param mixed $expression Expression
*/
public function __construct($expression)
{
if(is_object($expression) || is_resource($expression))
{
$expression = self::to_string($expression);
}

parent::__construct
([
'message' => 'Expression is not callable',
'expression' => $expression
'expression' => $this->to_string($expression)
]);
}
}
7 changes: 1 addition & 6 deletions source/InterfaceNotImplemented.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ class InterfaceNotImplemented extends LoggableException
*/
public function __construct($class, $interface)
{
if(is_object($class))
{
$class = get_class($class);
}

if(is_array($class))
{
parent::__construct($class);
Expand All @@ -29,7 +24,7 @@ public function __construct($class, $interface)
{
parent::__construct
([
'class' => $class,
'class' => $this->type_info($class),
'interface' => $interface
]);
}
Expand Down
2 changes: 1 addition & 1 deletion source/MethodNotCallable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct($method, $message = '')
}
else
{
parent::__construct(['method' => $method, 'message' => $message]);
parent::__construct(['method' => $this->to_string($method), 'message' => $message]);
}
}
}
4 changes: 2 additions & 2 deletions source/UnSerializeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
class UnSerializeException extends LoggableException
{
protected $template = 'Unserialize process was failed (type: {type}, node: {node}). {reason}';
protected $template = 'Unserialize process was failed (type: {type}, node: {node})';

/**
* Object can't be serialized!
Expand All @@ -25,7 +25,7 @@ public function __construct($reason, $type = 'phpserialize', $node = null)

parent::__construct
([
'reason' => $reason,
'message' => $reason,
'type' => $type,
'node' => $this->type_info($node)
]);
Expand Down
5 changes: 2 additions & 3 deletions source/UnhandledException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
class UnhandledException extends LoggableException
{
protected $template = 'Unhandled Exception {type} occurred';
protected $template = 'Unhandled Exception {type} occurred in the {source}';

/**
* @param \Exception|BaseExceptionI $exception
Expand All @@ -16,8 +16,7 @@ public function __construct(\Exception $exception)
{
parent::__construct
([
'message' => 'Unhandled Exception',
'type' => get_class($exception),
'type' => $this->type_info($exception),
'source' => $this->get_source_for($exception),
'previous' => $exception
]);
Expand Down

0 comments on commit 603de4c

Please sign in to comment.