HttpErrorResponse
一个用于表示错误或失败的响应对象,或者来自执行请求时发生的错误给出的失败的 HTTP 状态码,或者来自在解析响应对象期间发生的其它错误。
A response that represents an error or failure, either from a non-successful HTTP status, an error while executing the request, or some other failure which occurred during the parsing of the response.
class HttpErrorResponse extends HttpResponseBase implements Error {
constructor(init: {...})
get name: 'HttpErrorResponse'
get message: string
get error: any | null
get ok: false
// 继承自 common/http/HttpResponseBase
constructor(init: {...}, defaultStatus: number = 200, defaultStatusText: string = 'OK')
get headers: HttpHeaders
get status: number
get statusText: string
get url: string | null
get ok: boolean
get type: HttpEventType.Response | HttpEventType.ResponseHeader
}
说明
任何从 Observable
响应流中返回的错误都会被包装成 HttpErrorResponse
对象,以便在发生错误时,提供关于 HTTP 层状态的额外上下文信息。
该错误或者包含一个包装好的错误对象,或者包含一个从服务端返回的错误响应体。
Any error returned on the Observable
response stream will be
wrapped in an HttpErrorResponse
to provide additional context about
the state of the HTTP layer when the error occurred. The error property
will contain either a wrapped Error object or the error response returned
from the server.
构造函数
参数
|
属性
属性名 | 类型 | 说明 |
---|---|---|
name | 只读 | |
message | 只读 | |
error | 只读 | |
ok | 只读
只要是错误,其 Errors are never okay, even when the status code is in the 2xx success range. |