File: //usr/lib/python3/dist-packages/twisted/web/__pycache__/error.cpython-310.pyc
o
�b�2 � @ s8 d Z g d�ZddlmZ ddlmZ ddlmZ ddlm Z dd� Z
G d d
� d
e�ZG dd� de�Z
G d
d� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd � d e�ZG d!d"� d"e�ZG d#d$� d$e�ZG d%d&� d&e�Zd'S )(z+
Exception definitions for L{twisted.web}.
)�Error�PageRedirect�InfiniteRedirection�RenderError�MissingRenderMethod�MissingTemplateLoader�UnexposedMethodError�UnfilledSlot�UnsupportedType�FlattenerError�RedirectWithNoLocation� )�Sequence)�cast)�nativeString)� RESPONSESc C s* zt �t| ��W S ttfy Y dS w )a
Returns the response message corresponding to an HTTP code, or None
if the code is unknown or unrecognized.
@type code: L{bytes}
@param code: Refers to an HTTP status code, for example C{http.NOT_FOUND}.
@return: A string message or none
@rtype: L{bytes}
N)r �get�int�
ValueError�AttributeError)�code� r �3/usr/lib/python3/dist-packages/twisted/web/error.py�_codeToMessage s
�r c @ s( e Zd ZdZddd�Zdefdd�ZdS ) r aH
A basic HTTP error.
@type status: L{bytes}
@ivar status: Refers to an HTTP status code, for example C{http.NOT_FOUND}.
@type message: L{bytes}
@param message: A short error message, for example "NOT FOUND".
@type response: L{bytes}
@ivar response: A complete HTML document for an error page.
Nc C sF |pt |�}t�| |||� t|t�rd|f }|| _|| _|| _dS )a)
Initializes a basic exception.
@type code: L{bytes} or L{int}
@param code: Refers to an HTTP status code (for example, 200) either as
an integer or a bytestring representing such. If no C{message} is
given, C{code} is mapped to a descriptive bytestring that is used
instead.
@type message: L{bytes}
@param message: A short error message, for example "NOT FOUND".
@type response: L{bytes}
@param response: A complete HTML document for an error page.
s %dN)r � Exception�__init__�
isinstancer �status�message�response)�selfr r r r r r r >