mirror of
https://github.com/LukeHagar/plex-sdk-docs.git
synced 2025-12-06 12:37:46 +00:00
45 lines
909 B
Plaintext
45 lines
909 B
Plaintext
{/* Start Go Errors */}
|
|
Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass.
|
|
|
|
|
|
|
|
### Example
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"github.com/LukeHagar/plexgo"
|
|
"github.com/LukeHagar/plexgo/models/components"
|
|
"github.com/LukeHagar/plexgo/models/sdkerrors"
|
|
"log"
|
|
)
|
|
|
|
func main() {
|
|
s := plexgo.New(
|
|
plexgo.WithSecurity("<YOUR_API_KEY_HERE>"),
|
|
)
|
|
|
|
ctx := context.Background()
|
|
res, err := s.Server.GetServerCapabilities(ctx)
|
|
if err != nil {
|
|
|
|
var e *sdkerrors.GetServerCapabilitiesResponseBody
|
|
if errors.As(err, &e) {
|
|
// handle error
|
|
log.Fatal(e.Error())
|
|
}
|
|
|
|
var e *sdkerrors.SDKError
|
|
if errors.As(err, &e) {
|
|
// handle error
|
|
log.Fatal(e.Error())
|
|
}
|
|
}
|
|
}
|
|
|
|
```
|
|
{/* End Go Errors */}
|