Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

error return adjustment for client #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strconv"
"log"
)

const (
Expand Down Expand Up @@ -135,9 +136,14 @@ func (c *Client) StoreContext(ctx context.Context, req Request, dest string) err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return errors.New("failed to generate the result PDF")
if resp.StatusCode >= http.StatusBadRequest {
return fmt.Errorf("failed to generate the result PDF - http status code: [%d]", resp.StatusCode) // more details here now!
}

if resp.StatusCode < http.StatusOK {
return log.Printf("http status code: [%d]") // maybe the gotenburg server is still processing the request etc - this could be passed through as a bool maybe.
}

return writeNewFile(dest, resp.Body)
}

Expand Down