Skip to content

Commit

Permalink
better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed May 9, 2024
1 parent 9cf5f2c commit a63bce9
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions tools/tenscan/backend/webserver/webserver_routes_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (w *WebServer) getHealthStatus(c *gin.Context) {
func (w *WebServer) getLatestBatch(c *gin.Context) {
batch, err := w.backend.GetLatestBatch()
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getLatestBatch request %w", err), w.logger)
return
}

Expand All @@ -57,7 +57,7 @@ func (w *WebServer) getLatestBatch(c *gin.Context) {
func (w *WebServer) getLatestRollupHeader(c *gin.Context) {
rollup, err := w.backend.GetLatestRollupHeader()
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getLatestRollupHeader request %w", err), w.logger)
return
}

Expand All @@ -69,7 +69,7 @@ func (w *WebServer) getBatch(c *gin.Context) {
parsedHash := gethcommon.HexToHash(hash)
batch, err := w.backend.GetBatchByHash(parsedHash)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getBatch request %w", err), w.logger)
return
}

Expand All @@ -83,7 +83,7 @@ func (w *WebServer) getBatchByHeight(c *gin.Context) {
heightBigInt.SetString(heightStr, 10)
batch, err := w.backend.GetBatchByHeight(heightBigInt)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getBatchByHeight request %w", err), w.logger)
return
}

Expand All @@ -101,7 +101,7 @@ func (w *WebServer) getRollupBySeq(c *gin.Context) {

batch, err := w.backend.GetRollupBySeqNo(seq)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getRollupBySeq request %w", err), w.logger)
return
}

Expand All @@ -113,7 +113,7 @@ func (w *WebServer) getBatchHeader(c *gin.Context) {
parsedHash := gethcommon.HexToHash(hash)
batch, err := w.backend.GetBatchHeader(parsedHash)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getBatchHeader request %w", err), w.logger)
return
}

Expand All @@ -125,7 +125,7 @@ func (w *WebServer) getTransaction(c *gin.Context) {
parsedHash := gethcommon.HexToHash(hash)
batch, err := w.backend.GetTransaction(parsedHash)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getTransaction request %w", err), w.logger)
return
}

Expand All @@ -138,19 +138,19 @@ func (w *WebServer) getPublicTransactions(c *gin.Context) {

offset, err := strconv.ParseUint(offsetStr, 10, 32)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getPublicTransactions offset units %w", err), w.logger)
return
}

parseUint, err := strconv.ParseUint(sizeStr, 10, 64)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getPublicTransactions size units %w", err), w.logger)
return
}

publicTxs, err := w.backend.GetPublicTransactions(offset, parseUint)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getPublicTransactions request %w", err), w.logger)
return
}

Expand All @@ -161,7 +161,7 @@ func (w *WebServer) getTotalTxCount(c *gin.Context) {

txCount, err := w.backend.GetTotalTransactionCount()
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getTotalTxCount request %w", err), w.logger)
return
}

Expand All @@ -174,19 +174,19 @@ func (w *WebServer) getBatchListingNew(c *gin.Context) {

offset, err := strconv.ParseUint(offsetStr, 10, 32)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getBatchListingNew offset units %w", err), w.logger)
return
}

parseUint, err := strconv.ParseUint(sizeStr, 10, 64)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getBatchListingNew size units %w", err), w.logger)
return
}

batchesListing, err := w.backend.GetBatchesListing(offset, parseUint)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getBatchListingNew request %w", err), w.logger)
return
}

Expand All @@ -199,19 +199,19 @@ func (w *WebServer) getBatchListingDeprecated(c *gin.Context) {

offset, err := strconv.ParseUint(offsetStr, 10, 32)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getBatchListingDeprecated offset units %w", err), w.logger)
return
}

parseUint, err := strconv.ParseUint(sizeStr, 10, 64)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getBatchListingDeprecated size units %w", err), w.logger)
return
}

batchesListing, err := w.backend.GetBatchesListingDeprecated(offset, parseUint)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getBatchListingDeprecated request %w", err), w.logger)
return
}

Expand All @@ -224,19 +224,19 @@ func (w *WebServer) getRollupListing(c *gin.Context) {

offset, err := strconv.ParseUint(offsetStr, 10, 32)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getRollupListing offset units %w", err), w.logger)
return
}

parseUint, err := strconv.ParseUint(sizeStr, 10, 64)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getRollupListing size units %w", err), w.logger)
return
}

rollupListing, err := w.backend.GetRollupListing(offset, parseUint)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getRollupListing request %w", err), w.logger)
return
}

Expand All @@ -249,19 +249,19 @@ func (w *WebServer) getBlockListing(c *gin.Context) {

offset, err := strconv.ParseUint(offsetStr, 10, 32)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getBlockListing offset units %w", err), w.logger)
return
}

parseUint, err := strconv.ParseUint(sizeStr, 10, 64)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to parse getBlockListing size units %w", err), w.logger)
return
}

batchesListing, err := w.backend.GetBlockListing(offset, parseUint)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getBlockListing request %w", err), w.logger)
return
}

Expand All @@ -273,7 +273,7 @@ func (w *WebServer) getRollup(c *gin.Context) {
parsedHash := gethcommon.HexToHash(hash)
rollup, err := w.backend.GetRollupByHash(parsedHash)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getRollup request %w", err), w.logger)
return
}

Expand All @@ -285,7 +285,7 @@ func (w *WebServer) getRollupBatches(c *gin.Context) {
parsedHash := gethcommon.HexToHash(hash)
batchListing, err := w.backend.GetRollupBatches(parsedHash)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getRollupBatches request %w", err), w.logger)
return
}

Expand All @@ -297,7 +297,7 @@ func (w *WebServer) getBatchTransactions(c *gin.Context) {
parsedHash := gethcommon.HexToHash(hash)
txListing, err := w.backend.GetBatchTransactions(parsedHash)
if err != nil {
errorHandler(c, fmt.Errorf("unable to execute request %w", err), w.logger)
errorHandler(c, fmt.Errorf("unable to execute getBatchTransactions request %w", err), w.logger)
return
}

Expand Down

0 comments on commit a63bce9

Please sign in to comment.