mirror of
https://github.com/emo2007/block-accounting.git
synced 2025-04-12 08:56:28 +00:00
24 lines
394 B
Go
24 lines
394 B
Go
package rest
|
|
|
|
import "net/http"
|
|
|
|
type apiError struct {
|
|
Code int `json:"code"`
|
|
Error string `json:"error"`
|
|
}
|
|
|
|
func buildApiError(code int, message string) apiError {
|
|
return apiError{
|
|
Code: code,
|
|
Error: message,
|
|
}
|
|
}
|
|
|
|
func mapError(_ error) apiError {
|
|
// todo map typed errors
|
|
switch {
|
|
default:
|
|
return buildApiError(http.StatusInternalServerError, "Internal Server Error")
|
|
}
|
|
}
|