protonmail: log failed requests

This commit is contained in:
Simon Ser 2019-08-31 17:34:26 +03:00
parent 4b6614ca26
commit 4c2066d28f
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,8 @@ import (
"strconv" "strconv"
"golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp"
"log"
) )
const Version = 3 const Version = 3
@ -75,6 +77,8 @@ func (c *Client) newRequest(method, path string, body io.Reader) (*http.Request,
return nil, err return nil, err
} }
//log.Printf(">> %v %v\n", method, path)
req.Header.Set("X-Pm-Appversion", c.AppVersion) req.Header.Set("X-Pm-Appversion", c.AppVersion)
req.Header.Set(headerAPIVersion, strconv.Itoa(Version)) req.Header.Set(headerAPIVersion, strconv.Itoa(Version))
c.setRequestAuthorization(req) c.setRequestAuthorization(req)
@ -155,6 +159,7 @@ func (c *Client) doJSON(req *http.Request, respData interface{}) error {
if maybeError, ok := respData.(maybeError); ok { if maybeError, ok := respData.(maybeError); ok {
if err := maybeError.Err(); err != nil { if err := maybeError.Err(); err != nil {
log.Printf("request failed: %v %v: %v", req.Method, req.URL.String(), err)
return err return err
} }
} }