This page provides documentation for the error handling mechanisms available within the Go SDK.
The SDK defines several common error types, each representing a specific issue that might occur during API calls or other operations. Here are some of the most frequently encountered error types:
ErrorCodeUnknown
: This error indicates that the specific error code is not defined or recognized by the SDK. It's typically used as a fallback when an unexpected error occurs.
fmt.Errorf("unknown error code: %s", err.Error())
NotFoundError
: Indicates that a requested resource was not found.
if err := api.GetResource(resourceId); err != nil && err == errors.New("not found"); { ... }
PermissionDeniedError
: Indicates the user does not have the necessary permissions to perform the requested operation.
if err := api.UpdateResource(resourceId, data); err != nil && errors.Is(err, errors.PermissionDenied) { ... }
InvalidRequestError
: Raised when the request data is invalid.
if err := api.CreateResource(data); err != nil && errors.Is(err, errors.InvalidRequest) { ... }
The Go SDK provides several mechanisms for handling errors gracefully: