(c *APIClient) callAPI(request *http.Request) returns the error befor… #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…e producing an invalid APIResponse
It happens to me that (using phrase-cli) phrase push invocations may timeout. With this change, the timeout err is considered before the nil response is used to create a new APIResponse, that cause a SIGSEGV like
`[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x14062fa]
goroutine 1 [running]:
github.com/phrase/phrase-go.(*APIResponse).populatePageValues(0xc000411950)
/go/pkg/mod/github.com/phrase/[email protected]/response.go:82 +0x3a
github.com/phrase/phrase-go.NewAPIResponse(0x0, 0xc000615d00)
/go/pkg/mod/github.com/phrase/[email protected]/response.go:142 +0x59
github.com/phrase/phrase-go.(*APIClient).callAPI(0xc00021ec60, 0xc000615d00, 0xc0000d2180, 0xc000664c80, 0x4b)
/go/pkg/mod/github.com/phrase/[email protected]/client.go:260 +0x77
github.com/phrase/phrase-go.(*UploadsApiService).UploadCreate(0xc00021ec68, 0x181f4c0, 0xc0000d2180, 0xc00029c2a0, 0x20, 0xc00033b3f8, 0x0, 0x0, 0x0, 0x0, ...)
/go/pkg/mod/github.com/phrase/[email protected]/api_uploads.go:184 +0xb1a
github.com/phrase/phrase-cli/cmd/internal.(*Source).uploadFile(0xc0002de100, 0xc00021ec60, 0xc00019af50, 0x0, 0x0, 0x1, 0x1, 0x53)
/go/src/github.com/phrase/phrase-cli/cmd/internal/push_source.go:189 +0x22c
github.com/phrase/phrase-cli/cmd/internal.(*Source).Push(0xc0002de100, 0xc00021ec60, 0xc00033b800, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/phrase/phrase-cli/cmd/internal/push.go:162 +0x36c
github.com/phrase/phrase-cli/cmd/internal.(*PushCommand).Run(0xc0000e0000, 0x171fe76, 0x15)
/go/src/github.com/phrase/phrase-cli/cmd/internal/push.go:132 +0x77a
github.com/phrase/phrase-cli/cmd.initPush.func1(0xc00028f600, 0x1c14760, 0x0, 0x0)
/go/src/github.com/phrase/phrase-cli/cmd/push.go:26 +0x19b
github.com/spf13/cobra.(*Command).execute(0xc00028f600, 0x1c14760, 0x0, 0x0, 0xc00028f600, 0x1c14760)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0x1be00e0, 0x0, 0x0, 0x0)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/phrase/phrase-cli/cmd.Execute()
/go/src/github.com/phrase/phrase-cli/cmd/root.go:64 +0x2d
main.main()
/go/src/github.com/phrase/phrase-cli/main.go:8 +0x20`