Every error the server writes is the { error, code } envelope
(ErrorResponse); code is its stable identifier (NOT_FOUND,
BAD_REQUEST, UNAUTHORIZED, OVERLOADED, ...) and is what to branch on.
A body that is not the envelope (a proxy in front of the server answered,
or a server older than the envelope's coverage of every status) still
yields this error, with code set to HTTP_<status>.
Example
try { awaitclient.getCached(key); } catch (error) { if (errorinstanceofIfcServerError && error.code === 'OVERLOADED') { // retry later } }
A non-2xx answer from the server.
Every error the server writes is the
{ error, code }envelope (ErrorResponse);codeis its stable identifier (NOT_FOUND,BAD_REQUEST,UNAUTHORIZED,OVERLOADED, ...) and is what to branch on. A body that is not the envelope (a proxy in front of the server answered, or a server older than the envelope's coverage of every status) still yields this error, withcodeset toHTTP_<status>.Example