ApiException.php 505 B

123456789101112131415161718192021222324
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * API exception
  5. * @author wesmiler
  6. */
  7. namespace App\Exception;
  8. use App\Constants\ErrorCode;
  9. use Hyperf\Server\Exception\ServerException;
  10. use Throwable;
  11. class ApiException extends ServerException
  12. {
  13. public function __construct(int $code = 0, string $message = null, Throwable $previous = null)
  14. {
  15. if (is_null($message)) {
  16. $message = ErrorCode::getMessage($code);
  17. }
  18. parent::__construct($message, $code, $previous);
  19. }
  20. }