2021-05-12 06:35:00 +00:00
|
|
|
import { ValueOf } from 'type-fest';
|
2020-11-10 00:30:27 +00:00
|
|
|
|
2020-11-11 22:44:03 +00:00
|
|
|
export const GrpcStatusEnum = {
|
2020-11-10 00:30:27 +00:00
|
|
|
OK: 0,
|
|
|
|
CANCELLED: 1,
|
|
|
|
UNKNOWN: 2,
|
|
|
|
INVALID_ARGUMENT: 3,
|
|
|
|
DEADLINE_EXCEEDED: 4,
|
|
|
|
NOT_FOUND: 5,
|
|
|
|
ALREADY_EXISTS: 6,
|
|
|
|
PERMISSION_DENIED: 7,
|
|
|
|
RESOURCE_EXHAUSTED: 8,
|
|
|
|
FAILED_PRECONDITION: 9,
|
|
|
|
ABORTED: 10,
|
|
|
|
OUT_OF_RANGE: 11,
|
|
|
|
UNIMPLEMENTED: 12,
|
|
|
|
INTERNAL: 13,
|
|
|
|
UNAVAILABLE: 14,
|
|
|
|
DATA_LOSS: 15,
|
|
|
|
UNAUTHENTICATED: 16,
|
2021-05-12 06:35:00 +00:00
|
|
|
} as const;
|
2020-11-10 00:30:27 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
type GrpcStatus = ValueOf<typeof GrpcStatusEnum>;
|
2020-11-10 00:30:27 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
export interface GrpcStatusObject {
|
|
|
|
code: GrpcStatus;
|
|
|
|
details: string;
|
|
|
|
metadata: Record<string, any>; // https://grpc.github.io/grpc/node/grpc.Metadata.html
|
|
|
|
}
|
2020-11-10 00:30:27 +00:00
|
|
|
|
|
|
|
export type ServiceError = GrpcStatusObject & Error;
|