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 by the Memco-scopedgoogle.rpc.ErrorInfothe call carries: a sunset becomes a MemcoSunsetError, and a refused placement the subclass its reason names. Any other precondition failure — an unknown reason included — stays a MemcoPreconditionFailedError, carrying whatever metadata the service attached. Any code with no entry becomes a MemcoInternalError, which is where an unrecognised status belongs — it is not something the caller did.