mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
fix: add http error responses (#494)
This features adds rfc7807 Problem detail responses when an error happens processing a request. This will greatly improve the common issues with "blank pages" and "404 pages" issues which should now properly tell the user what input was wrong (group that does not exist, container name that does not exist, etc.)
This commit is contained in:
31
app/sessions/errors.go
Normal file
31
app/sessions/errors.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package sessions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ErrGroupNotFound struct {
|
||||
Group string
|
||||
AvailableGroups []string
|
||||
}
|
||||
|
||||
func (g ErrGroupNotFound) Error() string {
|
||||
return fmt.Sprintf("group %s not found", g.Group)
|
||||
}
|
||||
|
||||
type ErrRequestBinding struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e ErrRequestBinding) Error() string {
|
||||
return e.Err.Error()
|
||||
}
|
||||
|
||||
type ErrTimeout struct {
|
||||
Duration time.Duration
|
||||
}
|
||||
|
||||
func (e ErrTimeout) Error() string {
|
||||
return fmt.Sprintf("timeout after %s", e.Duration)
|
||||
}
|
||||
Reference in New Issue
Block a user