UnauthorizedHttpException.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\web;
  8. /**
  9. * UnauthorizedHttpException represents an "Unauthorized" HTTP exception with status code 401.
  10. *
  11. * Use this exception to indicate that a client needs to authenticate via WWW-Authenticate header
  12. * to perform the requested action.
  13. *
  14. * If the client is already authenticated and is simply not allowed to
  15. * perform the action, consider using a 403 [[ForbiddenHttpException]]
  16. * or 404 [[NotFoundHttpException]] instead.
  17. *
  18. * @link https://tools.ietf.org/html/rfc7235#section-3.1
  19. * @author Dan Schmidt <danschmidt5189@gmail.com>
  20. * @since 2.0
  21. */
  22. class UnauthorizedHttpException extends HttpException
  23. {
  24. /**
  25. * Constructor.
  26. * @param string $message error message
  27. * @param int $code error code
  28. * @param \Exception $previous The previous exception used for the exception chaining.
  29. */
  30. public function __construct($message = null, $code = 0, \Exception $previous = null)
  31. {
  32. parent::__construct(401, $message, $code, $previous);
  33. }
  34. }