All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 4m19s
22 lines
598 B
Go
22 lines
598 B
Go
package handler
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
"spend-sparrow/service"
|
|
"spend-sparrow/utils"
|
|
)
|
|
|
|
func handleError(w http.ResponseWriter, r *http.Request, err error) {
|
|
if errors.Is(err, service.ErrUnauthorized) {
|
|
utils.TriggerToastWithStatus(w, r, "error", "You are not autorized to perform this operation.", http.StatusUnauthorized)
|
|
return
|
|
} else if errors.Is(err, service.ErrBadRequest) {
|
|
utils.TriggerToastWithStatus(w, r, "error", err.Error(), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
utils.TriggerToastWithStatus(w, r, "error", "Internal Server Error", http.StatusInternalServerError)
|
|
}
|