From aca88cd780d435a0f72c6fc234c2322c7f39acdb Mon Sep 17 00:00:00 2001 From: Eric Wollesen Date: Tue, 24 Oct 2023 17:09:41 -0600 Subject: [PATCH] improved error reporting and fix placeholder name These changes partially address issues brought up during code review. More changes to come. BACK-2500 --- api/hydrophoneApi.go | 1 + api/invite.go | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/api/hydrophoneApi.go b/api/hydrophoneApi.go index 344261231..7845cd1aa 100644 --- a/api/hydrophoneApi.go +++ b/api/hydrophoneApi.go @@ -68,6 +68,7 @@ const ( STATUS_ERR_FINDING_CLINIC = "Error finding the clinic" STATUS_ERR_DECODING_CONFIRMATION = "Error decoding the confirmation" STATUS_ERR_DECODING_CONTEXT = "Error decoding the confirmation context" + STATUS_ERR_VALIDATING_CONTEXT = "Error validating the confirmation context" STATUS_ERR_CREATING_PATIENT = "Error creating patient" STATUS_ERR_FINDING_PREVIEW = "Error finding the invite preview" STATUS_ERR_CREATING_ALERTS_CONFIG = "Error creating alerts configuration" diff --git a/api/invite.go b/api/invite.go index 42bca3930..fafd27ce4 100644 --- a/api/invite.go +++ b/api/invite.go @@ -249,7 +249,7 @@ func (a *Api) AcceptInvite(res http.ResponseWriter, req *http.Request, vars map[ log.Printf("AcceptInvite error validating CareTeamContext: %s", err) a.sendModelAsResWithStatus( res, - &status.StatusError{Status: status.NewStatus(http.StatusForbidden, statusForbiddenMessage)}, + &status.StatusError{Status: status.NewStatus(http.StatusBadRequest, STATUS_ERR_VALIDATING_CONTEXT)}, http.StatusForbidden, ) return @@ -485,7 +485,7 @@ func (a *Api) SendInvite(res http.ResponseWriter, req *http.Request, vars map[st invite, err := models.NewConfirmationWithContext(models.TypeCareteamInvite, templateName, invitorID, ib.CareTeamContext) if err != nil { - statusErr := &status.StatusError{Status: status.NewStatus(http.StatusConflict, statusInternalServerErrorMessage)} + statusErr := &status.StatusError{Status: status.NewStatus(http.StatusInternalServerError, statusInternalServerErrorMessage)} a.sendModelAsResWithStatus(res, statusErr, http.StatusInternalServerError) return } @@ -505,10 +505,8 @@ func (a *Api) SendInvite(res http.ResponseWriter, req *http.Request, vars map[st a.sendModelAsResWithStatus(res, invite, http.StatusOK) } - fullName := "Mickey Mouse" - if invite.Creator.Profile == nil { - log.Printf("no creator profile for the invite") - } else { + fullName := "Tidepool User" + if invite.Creator.Profile != nil { fullName = invite.Creator.Profile.FullName if invite.Creator.Profile.Patient.IsOtherPerson { fullName = invite.Creator.Profile.Patient.FullName