Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(readme): improve example snippets #50

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ When the API returns a non-success status code, we return an error with type
To handle errors, we recommend that you use the `errors.As` pattern:

```go
_, err := client.HRIS.Directory.List(context.TODO(), finchgo.HRISDirectoryListParams{})
_, err := client.HRIS.Company.Get(context.TODO())
if err != nil {
var apierr *finchgo.Error
if errors.As(err, &apierr) {
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
}
panic(err.Error()) // GET "/employer/directory": 400 Bad Request { ... }
panic(err.Error()) // GET "/employer/company": 400 Bad Request { ... }
}
```

Expand Down
2 changes: 1 addition & 1 deletion paginationauto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAutoPagination(t *testing.T) {
// Prism mock isn't going to give us real pagination
for i := 0; i < 3 && iter.Next(); i++ {
directory := iter.Current()
t.Logf("%+v\n", directory)
t.Logf("%+v\n", directory.ID)
}
if err := iter.Err(); err != nil {
t.Fatalf("err should be nil: %s", err.Error())
Expand Down
4 changes: 2 additions & 2 deletions paginationmanual_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestManualPagination(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
for _, directory := range page.Individuals {
t.Logf("%+v\n", directory)
t.Logf("%+v\n", directory.ID)
}
// Prism mock isn't going to give us real pagination
page, err = page.GetNextPage()
Expand All @@ -38,7 +38,7 @@ func TestManualPagination(t *testing.T) {
}
if page != nil {
for _, directory := range page.Individuals {
t.Logf("%+v\n", directory)
t.Logf("%+v\n", directory.ID)
}
}
}