Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UserFriendlyError ¶
UserFriendlyError converts API errors to user-friendly messages. Backend codes win over status codes — they encode the precise denial reason (policy block vs. provider rejection vs. token gate).
Types ¶
type APIError ¶
type APIError struct {
StatusCode int `json:"-"`
Code string `json:"code,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
LegacyError string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
AccessInfo string `json:"accessInfo,omitempty"`
Details string `json:"details,omitempty"`
ConnectedProviders []string `json:"connectedProviders,omitempty"`
}
APIError represents an error response from the API. The backend uses two shapes:
- {code, message} — most endpoints
- {success:false, errorCode, errorMessage} — send/reply/forward
GET on a single email/thread may also return 404 with {accessInfo} to signal a policy denial (vs. genuinely missing).
func ParseAPIError ¶
ParseAPIError extracts error details from an HTTP response. NOTE: This function does NOT close resp.Body - caller is responsible for closing. This allows the caller to use defer resp.Body.Close() consistently.
func (*APIError) EffectiveCode ¶ added in v0.3.0
EffectiveCode returns the backend error code from whichever shape the response used. Empty when neither field is populated.
func (*APIError) EffectiveMessage ¶ added in v0.3.0
EffectiveMessage returns the user-facing description from whichever shape the response used. The 422 shape carries it in `message`; the send/reply/forward/modify/delete shape carries it in `errorMessage`; the legacy Drive 404 shape (`{ "error": "..." }`) carries it in `error`. All three are user-formatted and include my.porteden.com deep links / actionable guidance — prefer any of them over our own generic fallbacks.