Skip to content

Improve error message #218

Answered by baywet
Subhajit97 asked this question in Q&A
Jul 15, 2022 · 2 comments · 7 replies
Discussion options

You must be logged in to vote

Hi @Subhajit97
Thanks for using the Go SDK and for reaching out.
We've just had a community contribution yesterday that documents how to getter better information from the errors are you can see here

import (
    "github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
)

result, err := client.Me().Drive().Get()
if err != nil {
    fmt.Printf("Error getting the drive: %v\n", err)
    printOdataError(err)
}
fmt.Printf("Found Drive : %v\n", *result.GetId())

// omitted for brevity

func printOdataError(err error) {
	switch err.(type) {
	case *odataerrors.ODataError:
		typed := err.(*odataerrors.ODataError)
		fmt.Printf("error:", typed.Error())
		if terr := typed.GetError(); terr != nil

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@Subhajit97
Comment options

Answer selected by Subhajit97
Comment options

You must be logged in to vote
6 replies
@stephenwan-opal
Comment options

@baywet
Comment options

@stephenwan-opal
Comment options

@baywet
Comment options

@stephenwan-opal
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants