You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
625 B
27 lines
625 B
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Admin
|
|
* Date: 2018/11/14
|
|
* Time: 19:46
|
|
*/
|
|
|
|
namespace app\lib\factory;
|
|
|
|
|
|
use app\lib\enum\ExceptionType;
|
|
use app\lib\exception\HtmlException;
|
|
use app\lib\exception\JsonException;
|
|
|
|
class ExceptionFactory
|
|
{
|
|
public static function get($type,$errorMsg=""){
|
|
if($type == ExceptionType::HTML){
|
|
return new HtmlException($errorMsg);
|
|
} else if($type == ExceptionType::JSON){
|
|
return new JsonException(1,$errorMsg);
|
|
} else {
|
|
throw new \Exception("exceptionType must be HTML or JSON");
|
|
}
|
|
}
|
|
} |