<?php

class Requests_Exception_HTTP extends Requests_Exception
{
    protected $code = 0;
    protected $reason = 'Unknown';
    public function __construct($reason = null, $data = null)
    {
        if ($reason !== null) {
            $this->reason = $reason;
        }
        $message = sprintf('%d %s', $this->code, $this->reason);
        parent::__construct($message, 'httpresponse', $data, $this->code);
    }
    public function getReason()
    {
        return $this->reason;
    }
    public static function get_class($code)
    {
        if (!$code) {
            return 'Requests_Exception_HTTP_Unknown';
        }
        $class = sprintf('Requests_Exception_HTTP_%d', $code);
        if (class_exists($class)) {
            return $class;
        }
        return 'Requests_Exception_HTTP_Unknown';
    }
}