Class: Status
The Status
type defines a logical error model that is suitable for
different programming environments, including REST APIs and RPC APIs. It is
used by gRPC. Each Status
message contains
three pieces of data: error code, error message, and error details.
You can find out more about this error model and how to work with it in the API Design Guide.
Implements
Constructors
constructor
• new Status(properties?
): Status
Constructs a new Status.
Parameters
Name | Type | Description |
---|---|---|
properties? | IStatus | Properties to set |
Returns
Properties
code
• code: number
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
Implementation of
details
• details: IAny
[]
A list of messages that carry the error details. There is a common set of message types for APIs to use.
Implementation of
message
• message: string
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
Implementation of
Methods
toJSON
▸ toJSON(): Object
Converts this Status to JSON.
Returns
Object
JSON object
create
▸ create(properties?
): Status
Creates a new Status instance using the specified properties.
Parameters
Name | Type | Description |
---|---|---|
properties? | IStatus | Properties to set |
Returns
Status instance
decode
▸ decode(reader
, length?
): Status
Decodes a Status message from the specified reader or buffer.
Parameters
Name | Type | Description |
---|---|---|
reader | Uint8Array | Reader | Reader or buffer to decode from |
length? | number | Message length if known beforehand |
Returns
Status
Throws
If the payload is not a reader or valid buffer
Throws
If required fields are missing
decodeDelimited
▸ decodeDelimited(reader
): Status
Decodes a Status message from the specified reader or buffer, length delimited.
Parameters
Name | Type | Description |
---|---|---|
reader | Uint8Array | Reader | Reader or buffer to decode from |
Returns
Status
Throws
If the payload is not a reader or valid buffer
Throws
If required fields are missing
encode
▸ encode(message
, writer?
): Writer
Encodes the specified Status message. Does not implicitly google.rpc.Status.verify|verify messages.
Parameters
Name | Type | Description |
---|---|---|
message | IStatus | Status message or plain object to encode |
writer? | Writer | Writer to encode to |
Returns
Writer
Writer
encodeDelimited
▸ encodeDelimited(message
, writer?
): Writer
Encodes the specified Status message, length delimited. Does not implicitly google.rpc.Status.verify|verify messages.
Parameters
Name | Type | Description |
---|---|---|
message | IStatus | Status message or plain object to encode |
writer? | Writer | Writer to encode to |
Returns
Writer
Writer
fromObject
▸ fromObject(object
): Status
Creates a Status message from a plain object. Also converts values to their respective internal types.
Parameters
Name | Type | Description |
---|---|---|
object | Object | Plain object |
Returns
Status
getTypeUrl
▸ getTypeUrl(typeUrlPrefix?
): string
Gets the default type url for Status
Parameters
Name | Type | Description |
---|---|---|
typeUrlPrefix? | string | your custom typeUrlPrefix(default "type.googleapis.com") |
Returns
string
The default type url
toObject
▸ toObject(message
, options?
): Object
Creates a plain object from a Status message. Also converts values to other types if specified.
Parameters
Name | Type | Description |
---|---|---|
message | Status | Status |
options? | IConversionOptions | Conversion options |
Returns
Object
Plain object