Skip to content

Commit

Permalink
stick our error details in our response instead of description
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Aug 24, 2017
1 parent f497ebf commit 382af9a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backends/rapidpro/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ func writeChannelLog(b *backend, log *courier.ChannelLog) error {

description := "Success"
if log.Error != "" {
description = fmt.Sprintf("Error: %s", log.Error)
description = "Error"

// we append our error to our response as it can be long
log.Response += "\n\nError: " + log.Error
}

_, err := b.db.Exec(insertLogSQL, dbChan.ID(), log.MsgID, description[:255], log.Error != "", log.Method, log.URL,
_, err := b.db.Exec(insertLogSQL, dbChan.ID(), log.MsgID, description, log.Error != "", log.Method, log.URL,
log.Request, log.Response, log.StatusCode, log.CreatedOn, log.Elapsed/time.Millisecond)

return err
Expand Down
24 changes: 24 additions & 0 deletions utils/http_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package utils

import "testing"

func TestClient(t *testing.T) {
client := GetHTTPClient()
if client == nil {
t.Error("Client should not be nil")
}

insecureClient := GetInsecureHTTPClient()
if insecureClient == nil {
t.Error("Insecure client should not be nil")
}

if client == insecureClient || client.Transport == insecureClient.Transport {
t.Error("Client and insecure client should not be the same")
}

client2 := GetHTTPClient()
if client != client2 {
t.Error("GetHTTPClient should always return same client")
}
}

0 comments on commit 382af9a

Please sign in to comment.