/
errors.go
48 lines (35 loc) · 1.1 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package broker
import (
"fmt"
"net/http"
)
type ApplicationNotFoundError string
func (e ApplicationNotFoundError) Error() string {
return fmt.Sprintf("Application '%s' not found", string(e))
}
func (e ApplicationNotFoundError) HTTPErrorStatusCode() int {
return http.StatusNotFound
}
type ApplicationExistError struct {
Name, Namespace string
}
func (e ApplicationExistError) Error() string {
return fmt.Sprintf("The application '%s' already exists in the namespace '%s'", e.Name, e.Namespace)
}
func (e ApplicationExistError) HTTPErrorStatusCode() int {
return http.StatusConflict
}
type NoNamespaceError string
func (e NoNamespaceError) Error() string {
return fmt.Sprintf("No namespace created for the user '%s'", string(e))
}
func (e NoNamespaceError) HTTPErrorStatusCode() int {
return http.StatusBadRequest
}
type NamespaceNotEmptyError string
func (e NamespaceNotEmptyError) Error() string {
return fmt.Sprintf("Cannot remove namespace '%s' because it contains one or more applications", string(e))
}
func (e NamespaceNotEmptyError) HTTPErrorStatusCode() int {
return http.StatusForbidden
}