Skip to content

Commit

Permalink
bulkerapp: fix for all router handlers error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Aug 25, 2023
1 parent fa6e48e commit f668c64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions bulkerapp/app/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions jitsubase/appbase/router_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit f668c64

Please sign in to comment.