diff --git a/bulkerapp/app/router.go b/bulkerapp/app/router.go index c16d9d1..56ef8a3 100644 --- a/bulkerapp/app/router.go +++ b/bulkerapp/app/router.go @@ -93,9 +93,9 @@ func (r *Router) EventsHandler(c *gin.Context) { tableName := c.Query("tableName") mode := "" bytesRead := 0 - var rError appbase.RouterError + var rError *appbase.RouterError defer func() { - if rError.Error != nil { + if rError != nil { metrics.EventsHandlerRequests(destinationId, mode, tableName, "error", rError.ErrorType).Inc() } else { metrics.EventsHandlerRequests(destinationId, mode, tableName, "success", "").Inc() @@ -153,9 +153,9 @@ func (r *Router) BulkHandler(c *gin.Context) { mode := "" bytesRead := 0 - var rError appbase.RouterError + var rError *appbase.RouterError defer func() { - if rError.Error != nil { + if rError != nil { metrics.BulkHandlerRequests(destinationId, mode, tableName, "error", rError.ErrorType).Inc() } else { metrics.BulkHandlerRequests(destinationId, mode, tableName, "success", "").Inc() @@ -239,7 +239,7 @@ func (r *Router) IngestHandler(c *gin.Context) { domain := "" // TODO: use workspaceId as default for all stream identification errors var eventsLogId string - var rError appbase.RouterError + var rError *appbase.RouterError var body []byte var asyncDestinations []string var tagsDestinations []string @@ -254,7 +254,7 @@ func (r *Router) IngestHandler(c *gin.Context) { } body, _ = json.Marshal(bodyJsonObj) } - if rError.ErrorType != "" { + if rError != nil { obj := map[string]any{"body": string(body), "error": rError.PublicError.Error(), "status": "FAILED"} r.eventsLogService.PostAsync(&ActorEvent{EventTypeIncomingError, eventsLogId, obj}) r.eventsLogService.PostAsync(&ActorEvent{EventTypeIncomingAll, eventsLogId, obj}) diff --git a/jitsubase/appbase/router_base.go b/jitsubase/appbase/router_base.go index 20eb0ee..e188e08 100644 --- a/jitsubase/appbase/router_base.go +++ b/jitsubase/appbase/router_base.go @@ -91,7 +91,7 @@ func (r *Router) authMiddleware(c *gin.Context) { return } -func (r *Router) ResponseError(c *gin.Context, code int, errorType string, maskError bool, err error, logFormat string, logArgs ...any) RouterError { +func (r *Router) ResponseError(c *gin.Context, code int, errorType string, maskError bool, err error, logFormat string, logArgs ...any) *RouterError { routerError := RouterError{Error: err, ErrorType: errorType} if err != nil { if maskError { @@ -114,7 +114,7 @@ func (r *Router) ResponseError(c *gin.Context, code int, errorType string, maskE logArgs = append(logArgs, err) r.Errorf(logFormat, logArgs...) c.JSON(code, gin.H{"error": routerError.PublicError.Error()}) - return routerError + return &routerError } func HashToken(token string, salt string, secret string) string {