Function fromServiceError
-
Parameters
- error: Partial<ServiceError>
The rejection
@grpc/grpc-jsproduced.
Returns MemcoAPIError
The typed error to raise.
- error: Partial<ServiceError>
The rejection @grpc/grpc-js produced.
The typed error to raise.
Translate a gRPC failure into the error that says what happened.
Returns rather than throws, so a caller can add context before raising.
The mapping is by status code, with
FAILED_PRECONDITIONsplitting further: when the call carries a Memco-scopedgoogle.rpc.ErrorInfonaming a sunset, the result is a MemcoSunsetError. Any code with no entry becomes a MemcoInternalError, which is where an unrecognised status belongs — it is not something the caller did.