oficina / agent-access Public

Clone
git clone https://amadan.net/oficina/agent-access

Plain git — no account needed to clone.

Download this file

1package agentaccess
2
3// FailureForStatus preserves the public error category without copying remote
4// prose. Bodies may contain app content, HTML, credentials or proxy errors.
5// No transport failure proves that an attempted mutation did not commit.
6func FailureForStatus(status int) Failure {
7 switch status {
8 case 401:
9 return Failure{"unauthenticated", "Connect to Oficina again."}
10 case 403:
11 return Failure{"forbidden", "Current access does not allow this operation."}
12 case 404:
13 return Failure{"not_found", "The app or item is unavailable."}
14 case 409:
15 return Failure{"conflict", "Check the resource revision and retry identifier."}
16 case 413:
17 return Failure{"too_large", "The request or result exceeds the app's limit."}
18 case 415:
19 return Failure{"unsupported_media_type", "Send application/json."}
20 case 400, 422:
21 return Failure{"invalid", "Check the arguments against the operation schema."}
22 case 429:
23 return Failure{"rate_limited", "The app is busy. Try again later."}
24 case 500:
25 return Failure{"internal", "The app could not confirm the operation."}
26 default:
27 return Failure{"unavailable", "The app could not confirm the operation. Retry writes only with the original client_id and arguments."}
28 }
29}
30