Skip to content

Commit

Permalink
chore(BUX-223): refactor ErrorResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 committed Feb 22, 2024
1 parent 1cc6cd0 commit ba7e62f
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions server/error.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package server

import (
"encoding/json"
"errors"
"github.com/bitcoin-sv/go-paymail"
"github.com/gin-gonic/gin"
"net/http"
)

// Error codes for server response errors
Expand Down Expand Up @@ -60,12 +58,5 @@ var (
// Specs: http://bsvalias.org/99-01-recommendations.html
func ErrorResponse(c *gin.Context, code, message string, statusCode int) {
srvErr := &paymail.ServerError{Code: code, Message: message}
jsonData, err := json.Marshal(srvErr)

if err != nil {
c.JSON(http.StatusInternalServerError, ErrorFailedMarshalJSON)
return
}

c.JSON(statusCode, jsonData)
c.JSON(statusCode, srvErr)
}

0 comments on commit ba7e62f

Please sign in to comment.