Files
developer.sailpoint.com/docs/tools/sdk/go/error-handling.md
darrell-thobe-sp 2cd5ccfc81 Prettified Code!
2024-04-18 10:31:05 +00:00

1.4 KiB

id, title, pagination_label, sidebar_label, sidebar_position, sidebar_class_name, keywords, description, slug, tags
id title pagination_label sidebar_label sidebar_position sidebar_class_name keywords description slug tags
go-sdk-error-handling Error handling with the Go SDK Go SDK Error Handling 8 gosdk
go
golang
sdk
error
Learn how to handle errors with the Golang SDK in this guide. /tools/sdk/go/error-handling
SDK
Software Development Kit

The SDK returns the response object, request and error object for each method. The error object will be defined for any response status that falls out of the range of 2xx.

You can use an if statement to check whether there are any errors with the request and take actions on the results, such as logging the message or performing additional actions before exiting the program:

resp, r, err := apiClient.V3.TransformsApi.ListTransforms(ctx).Filters("This is an incorrect string").Execute()
if err != nil {
 fmt.Fprintf(os.Stderr, "Error when calling `TransformsApi.ListTransforms``: %v\n", err)
 fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

The program will continue running unless you specify to end it. Use os.Exit(0) within the error check to stop execution after an error is found.

resp, r, err := apiClient.V3.TransformsApi.ListTransforms(ctx).Filters("This is an incorrect string").Execute()
if err != nil {
 fmt.Fprintf(os.Stderr, "Error when calling `TransformsApi.ListTransforms``: %v\n", err)
 fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
 os.Exit(0)
}