| @@ 37-59 (lines=23) @@ | ||
| 34 | * Implementation of an error message. |
|
| 35 | * @author Celestino Diaz <[email protected]> |
|
| 36 | */ |
|
| 37 | class ErrorMessage extends GenericMessage { |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Error message parameter. |
|
| 41 | * @var string |
|
| 42 | */ |
|
| 43 | const PARAM_ERROR_MESSAGE = "errorMessage"; |
|
| 44 | ||
| 45 | /** @param string $errorMessage */ |
|
| 46 | public function __construct($errorMessage) { |
|
| 47 | Assert::isString($errorMessage); |
|
| 48 | parent::__construct(Messages::ERROR, null, [self::PARAM_ERROR_MESSAGE => $errorMessage]); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Returns the message containing the error occurred. |
|
| 53 | * @return string the error message |
|
| 54 | */ |
|
| 55 | public function getErrorMessage() { |
|
| 56 | return $this->getParam(self::PARAM_ERROR_MESSAGE); |
|
| 57 | } |
|
| 58 | ||
| 59 | } |
|
| 60 | ||
| @@ 36-57 (lines=22) @@ | ||
| 33 | * Implementation of an exception message. |
|
| 34 | * @author Celestino Diaz <[email protected]> |
|
| 35 | */ |
|
| 36 | class ExceptionMessage extends GenericMessage { |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Exception message parameter. |
|
| 40 | * @var string |
|
| 41 | */ |
|
| 42 | const PARAM_EXCEPTION = "exception"; |
|
| 43 | ||
| 44 | /** @param \Exception $exception */ |
|
| 45 | public function __construct(\Exception $exception) { |
|
| 46 | parent::__construct(Messages::EXCEPTION, null, [self::PARAM_EXCEPTION => $exception]); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Returns the message containing the exception occurred. |
|
| 51 | * @return \Exception the exception occurred |
|
| 52 | */ |
|
| 53 | public function getException() { |
|
| 54 | return $this->getParam(self::PARAM_EXCEPTION); |
|
| 55 | } |
|
| 56 | ||
| 57 | } |
|
| 58 | ||