framework/web/Response.php
public function setStatusCodeByException($e)
    {
        if ($e instanceof HttpException) {
            $this->setStatusCode($e->statusCode);
        } else {
            $this->setStatusCode(500);
        }

        return $this;
    }
public function setStatusCodeByException($e)
    {
        if ($e instanceof HttpException) {
            $this->setStatusCode($e->statusCode);
        } else {
            $this->setStatusCode(500);
        }

        return $this;
    }
Sets the response status code based on the exception.
@param \Exception|\Error $e the exception object.
@throws InvalidArgumentException if the status code is invalid.
@return $this the response object itself
@since 2.0.12