首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

webob exception

本文为扶艾原创文章,版权所有,禁止转载!

什么是webob

webob是一个python的包,它主要的作用是对wsgi的request进行修饰,以及帮助生成wsgi的response。下面主要看看异常处理。

webob exception

这个模块根据RFC 2068定义异常:100-300不算是真正的错误;400+是客户端错误,500+是服务端错误。

用法说明

属性:

code:HTTP状态码

title:状态行的剩余内容(状态码后面的内容)

detail:定制的明文信息

body_template:用于环境和头替换的内容片段(HTML);默认模板包括消息中提供的解释和详细信息

参数:

detail:重写默认的detail

headers:a list of(k,v) header pairs

comment:明文附加信息

body_template:a string.Template object containing a content fragment in HTML that frames the explanation and further detail

HTTPOK

200 HTTPOk

1webob.exc.HTTPOk(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#200+状态的基类(成功返回)

3#code:200,title:OK

201 HTTPCreated

1webob.exc.HTTPCreated(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPOk

3#表明请求已经完成,并创建了一个新的资源

4#code:201,title:Created

202 HTTPAccepted

1webob.exc.HTTPAccepted(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPOk

3#表明请求已经被处理,但处理尚未完成

4#code:202,title:Accepted

203 HTTPNonAuthoritativeInformation

1webob.exc.HTTPNonAuthoritativeInformation(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPOk

3#表明返回的报头信息不明确

4#code:203,title:Non-Authoritative Information

204 HTTPNoContent

1webob.exc.HTTPNoContent(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPOk

3#表明服务器已经完成了请求,但不必返回内容

4#code:204,title:No Content

205 HTTPResetContent

1webob.exc.HTTPResetContent(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPOk

3#表明服务器已经完成了请求,用户端应该重置发送该请求的视图

4#code:205,title:Reset Content

206 HTTPPartialContent

1webob.exc.HTTPPartialContent(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPOk

3#表明服务器已经完成了GET请求

4#code:206,title:Partial Content

HTTPREDIIRECTION

300 HTTPMultipleChoices

1webob.exc.HTTPMultipleChoices(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承_HTTPMove

3#表明请求对应的是一组资源中的其中一个,每一个都有自己特定的位置,用户可以选择重定向

4#code:300,title:Multiple Choices

301 HTTPMovedPermanently

1webob.exc.HTTPMovedPermanently(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承_HTTPMove

3#表明请求的资源已经被分配个一个xin的uri

4#code:301,title:Moved Permanently

302 HTTPFound

1webob.exc.HTTPFound(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承_HTTPMove

3#表明请求的资源暂时安置在不同的uri

4#code:302,title:Found

303 HTTPSeeOther

1webob.exc.HTTPSeeOther(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPRedirection

3#This indicates that the response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource.

4#code:303,title:See Other

304 HTTPNotModified

1webob.exc.HTTPNotModified(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承_HTTPMove

3#This indicates thatifthe client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond withthisstatus code.

4#code:304,title:Not Modified

305 HTTPUseProxy

1webob.exc.HTTPUseProxy(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承_HTTPMove

3#表明请求的资源必须通过由位置字段中指定的代理服务器访问

4#code:305,title:Use Proxy

307 HTTPTemporaryRedirect

1webob.exc.HTTPTemporaryRedirect(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承_HTTPMove

3#This indicates that the requested resource resides temporarily under a different URI.

4#code:307,title:Temporary Redirect

308 HTTPPermanentRedirect

HTTPERROR

HTTPClientError

400 HTTPBadRequest

401 HTTPUnauthorized

1webob.exc.HTTPUnauthorized(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明用户需要认证

4#code:401,title:Unauthorized

402 HTTPPaymentRequired

1webob.exc.HTTPPaymentRequired(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#code:402,title:Payment Required

403 HTTPForbidden

1webob.exc.HTTPForbidden(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明服务器拒绝访问

4#code:403,title:Forbidden

404 HTTPNotFound

1webob.exc.HTTPNotFound(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明该服务器没有找到任何匹配的 请求URI。

4#code:404,title:Not Found

405 HTTPMethodNotAllowed

1webob.exc.HTTPMethodNotAllowed(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明在请求行中指定的方法 不允许请求URI标识的资源。

4#code:405,title:Method Not Allowed

406 HTTPNotAcceptable

1webob.exc.HTTPNotAcceptable(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates the resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

4#code:406,title:Not Acceptable

407 HTTPProxyAuthenticationRequired

1webob.exc.HTTPProxyAuthenticationRequired(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#这是类似于401,但指出,客户端必须先 认证代理本身。

4#code:407,title:Proxy Authentication Required

408 HTTPRequestTimeout

1webob.exc.HTTPRequestTimeout(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明,客户端不在 等待服务器发出请求的时间。

4#code:408,title:Request Timeout

409 HTTPConflict

1webob.exc.HTTPConflict(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the request could not be completed due to a conflict with the current state of the resource.

4#code:409,title:Conflict

410 HTTPGone

1webob.exc.HTTPGone(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明请求的资源在服务器上不可用,不知道转发地址

4#code:410,title:Gone

411 HTTPLengthRequired

1webob.exc.HTTPLengthRequired(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明服务器拒绝接受没有定义Content-Length的请求

4#code:411,title: Length Required

412 HTTPPreconditionFailed

1webob.exc.HTTPPreconditionFailed(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the precondition given in one or more of the request-header fields evaluated tofalsewhen it was tested on the server.

4#code:412,title:Precondition Failed

413 HTTPRequestEntityTooLarge

1webob.exc.HTTPRequestEntityTooLarge(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the server is refusing to process a request because the request entity is larger than the server is willing or able to process.

4#code:413,title:Request Entity Too Large

414 HTTPRequestURITooLong

1webob.exc.HTTPRequestURITooLong(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the server is refusing to service the request because the Request-URI is longer than the server is willing to interpret.

4#code:414,title:Request-URI Too Long

415 HTTPUnsupportedMediaType

1webob.exc.HTTPUnsupportedMediaType(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the server is refusing to service the request because the entity of the request is in a format not supported by the requested resourceforthe requested method.

4#code:415,title:Unsupported Media Type

416 HTTPRequestRangeNotSatisfiable

1webob.exc.HTTPRequestRangeNotSatisfiable(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#The server SHOULDreturna response withthisstatus codeifa request included a Range request-header field, and none of the range-specifier values inthisfield overlap the current extent of the selected resource, and the request did not include an If-Range request-header field.

4#code:416,title:Request Range Not Satisfiable

417 HTTPExpectationFailed

1webob.exc.HTTPExpectationFailed(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indidcates that the expectation given in an Expect request-header field could not be met bythisserver.

4#code:417,title:Expectation Failed

422 HTTPUnprocessableEntity

1webob.exc.HTTPUnprocessableEntity(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明请求的参数格式不对

4#code:422,title:Unprocessable Entity

423 HTTPLocked

1webob.exc.HTTPLocked(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明请求的资源被锁定

4#code:423,title:Locked

424 HTTPFailedDependency

1webob.exc.HTTPFailedDependency(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#表明请求不能执行,因为依赖的另一个请求失败了

4#code:424,title:Failed Dependency

428 HTTPPreconditionRequired

1webob.exc.HTTPPreconditionRequired(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the origin serverrequiresthe request to be conditional. From RFC6585,"Additional HTTP Status Codes".

4#code:428,title:Precondition Required

429 HTTPTooManyRequests

1webob.exc.HTTPTooManyRequests(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the client has sent too many requests in a given amount of time. Usefulforrate limiting.

4#code:429,title:Too Many Requests

431 HTTPRequestHeaderFieldsTooLarge

1webob.exc.HTTPRequestHeaderFieldsTooLarge(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the server is unwilling to process the request because its header fields are too large. The request may be resubmitted after reducing the size of the request header fields.

4#code:431,title:Request Header Fields Too Large

451 HTTPUnavailableForLegalReasons

1webob.exc.HTTPUnavailableForLegalReasons(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPClientError

3#This indicates that the server is unable to process the request because of legal reasons, e.g. censorship or government-mandated blocked access.

4#code:451,title:Unavailable For Legal Reasons

HTTPServerError

500 HTTPInternalServerError

1webob.exc.HTTPInternalServerError(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPServerError

3#请求的功能出错

4#code:500,title:Internal Server Error

501 HTTPNotImplemented

1webob.exc.HTTPNotImplemented(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPServerError

3#表明该服务器不支持该功能 请求

4#code:501,title:Not Implemented

502 HTTPBadGateway

1webob.exc.HTTPBadGateway(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPServerError

3#This indicates that the server,whileacting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.

4#code:502,title:Bad Gateway

503 HTTPServiceUnavailable

1webob.exc.HTTPServiceUnavailable(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPServerError

3#表明服务器目前由于临时超载或服务器维护无法处理请求。

4#code:503,title:Service Unavailable

504 HTTPGatewayTimeout

1webob.exc.HTTPGatewayTimeout(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPServerError

3#This indicates that the server,whileacting as a gateway or proxy,did not receive a timely response from the upstream server specified by theURI(e.g. HTTP, FTP, LDAP)or some other auxiliaryserver(e.g. DNS)it needed to access in attempting to complete the request.

4#code:504,title:Gateway Timeout

5

505 HTTPVersionNotSupported

1webob.exc.HTTPVersionNotSupported(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPServerError

3#This indicates that the server does not support, or refuses to support, the HTTP protocol version that was used in the request message.

4#code:505,title:HTTP Version Not Supported

511 HTTPNetworkAuthenticationRequired

1webob.exc.HTTPNetworkAuthenticationRequired(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)

2#继承HTTPServerError

3#This indicates that the client needs to authenticate to gain network access. From RFC6585,

4#code:511,title:Network Authentication Required

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180503G1RRTX00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券