msgraph-sdk-go
msgraph-sdk-go copied to clipboard
Basic examples in documentation are wrong
Hello, I find this library rather hard to use and noticed that the basic examples as documented are not working. For example the following snippet in your README documents the generic error handling as follows:
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 {
fmt.Printf("code: %s", *terr.GetCode())
fmt.Printf("msg: %s", *terr.GetMessage())
}
default:
fmt.Printf("%T > error: %#v", err, err)
}
}
There's no typed.GetError() method anymore. I believe this was a breaking change and exist before. Today there's a typed.Error() method which returns a string.
Hi @weeco Thanks for using the SDK and for reaching out. I'm not sure I understand what the issue is here? there is a odataerror error method
Could you clarify please?
Apologies, I did a typo in one sentence - I correct it now. The missing method that you are referring to in your Readme is GetError()
Right there's an Error method here - which returns a string (see my initial post), but if you look at the copied snippet I took from your README you can see that it's using a GetError() method which does not exist.
Thanks for clarifying. I believe it's now meant to be "GetErrorEscaped", it's ugly but it's to avoid collisions with native "Error" symbol. Would you be willing to submit a pull request to correct that please?
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
I ran into the same issue as described. Thanks for the declaration. :) I'm glad to help update the documentation with this pull request: https://github.com/microsoftgraph/msgraph-sdk-go/pull/802