mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
[NOD-464] Fix error messages in GetBlocks. (#500)
This commit is contained in:
parent
bdc3cbceaa
commit
5e9fc2defc
@ -86,7 +86,11 @@ func convertQueryParamToInt(queryParams map[string]string, param string, default
|
||||
if _, ok := queryParams[param]; ok {
|
||||
intValue, err := strconv.Atoi(queryParams[param])
|
||||
if err != nil {
|
||||
return 0, httpserverutils.NewHandlerError(http.StatusUnprocessableEntity, errors.Wrap(err, fmt.Sprintf("Couldn't parse the '%s' query parameter", param)))
|
||||
errorMessage := fmt.Sprintf("Couldn't parse the '%s' query parameter", param)
|
||||
return 0, httpserverutils.NewHandlerErrorWithCustomClientMessage(
|
||||
http.StatusUnprocessableEntity,
|
||||
errors.Wrap(err, errorMessage),
|
||||
errorMessage)
|
||||
}
|
||||
return intValue, nil
|
||||
}
|
||||
@ -159,7 +163,8 @@ func getBlocksHandler(_ *httpserverutils.ServerContext, _ *http.Request, _ map[s
|
||||
order := defaultGetBlocksOrder
|
||||
if orderParamValue, ok := queryParams[queryParamOrder]; ok {
|
||||
if orderParamValue != controllers.OrderAscending && orderParamValue != controllers.OrderDescending {
|
||||
return nil, httpserverutils.NewHandlerError(http.StatusUnprocessableEntity, errors.Errorf("'%s' is not a valid value for the '%s' query parameter", orderParamValue, queryParamLimit))
|
||||
return nil, httpserverutils.NewHandlerError(http.StatusUnprocessableEntity, errors.Errorf(
|
||||
"Couldn't parse the '%s' query parameter", queryParamLimit))
|
||||
}
|
||||
order = orderParamValue
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user