Skip to content

Commit

Permalink
fix exposing detailed AWS SDK error by event API. Closes #344 (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthenw authored Nov 24, 2017
1 parent 0ac2643 commit c5b413d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
20 changes: 0 additions & 20 deletions router/errors.go

This file was deleted.

9 changes: 3 additions & 6 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,15 @@ func (router *Router) handleHTTPEvent(event *eventpkg.Event, w http.ResponseWrit
event.Data = httpdata
resp, err := router.callFunction(*backingFunction, *event)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Error(w, "function call failed", http.StatusInternalServerError)
return
}

httpResponse := &HTTPResponse{StatusCode: http.StatusOK}
err = json.Unmarshal(resp, httpResponse)
if err != nil {
httperr := NewErrHTTPResponseObjectMalformed()
http.Error(w, httperr.Error(), httperr.StatusCode)

router.log.Info(httperr.Error(), zap.String("response", string(resp)))

router.log.Info("HTTP response object malformed.", zap.String("response", string(resp)))
http.Error(w, "HTTP response object malformed", http.StatusInternalServerError)
return
}

Expand Down

0 comments on commit c5b413d

Please sign in to comment.