Skip to content

Commit

Permalink
#5 The GeneralException introduced.
Browse files Browse the repository at this point in the history
  • Loading branch information
automatix committed Jul 19, 2018
1 parent a0c3884 commit 39f8249
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Base/Exceptions/GeneralErrorContextCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace App\Base\Exceptions;

/**
* Class GeneralErrorContextCode
*
* @method static GeneralErrorContextCode GENERAL_ERROR()
* @method static GeneralErrorContextCode INVALID_ARGUMENT()
*/
class GeneralErrorContextCode extends AbstractErrorCode
{

const GENERAL_ERROR = 1;
const INVALID_ARGUMENT = 2;

}
28 changes: 28 additions & 0 deletions src/Base/Exceptions/GeneralException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace App\Base\Exceptions;

use Exception;

/**
* Class GeneralException
*/
class GeneralException extends AbstractException
{

public function __construct($message = '', GeneralErrorContextCode $code, Exception $previous = null)
{
if ($code === null) {
$code = GeneralErrorContextCode::GENERAL_ERROR();
}
parent::__construct($message, $code, $previous);
}

/**
* @return string
*/
public function getContext()
{
return "GEN";
}

}

0 comments on commit 39f8249

Please sign in to comment.