@@ -34,51 +34,57 @@ func Error(w http.ResponseWriter, code int, err error) {
34
34
}
35
35
36
36
func VolumeNotFound (w http.ResponseWriter , name string , err error ) {
37
- if ! errors .Is (err , define .ErrNoSuchVolume ) {
38
- InternalServerError (w , err )
37
+ if errors .Is (err , define .ErrNoSuchVolume ) || errors .Is (err , define .ErrVolumeExists ) {
38
+ Error (w , http .StatusNotFound , err )
39
+ return
39
40
}
40
- Error ( w , http . StatusNotFound , err )
41
+ InternalServerError ( w , err )
41
42
}
42
43
43
44
func ContainerNotFound (w http.ResponseWriter , name string , err error ) {
44
45
if errors .Is (err , define .ErrNoSuchCtr ) || errors .Is (err , define .ErrCtrExists ) {
45
46
Error (w , http .StatusNotFound , err )
46
- } else {
47
- InternalServerError (w , err )
47
+ return
48
48
}
49
+ InternalServerError (w , err )
49
50
}
50
51
51
52
func ImageNotFound (w http.ResponseWriter , name string , err error ) {
52
53
if ! errors .Is (err , storage .ErrImageUnknown ) {
53
54
InternalServerError (w , err )
55
+ return
54
56
}
55
57
Error (w , http .StatusNotFound , err )
56
58
}
57
59
58
60
func NetworkNotFound (w http.ResponseWriter , name string , err error ) {
59
61
if ! errors .Is (err , define .ErrNoSuchNetwork ) {
60
62
InternalServerError (w , err )
63
+ return
61
64
}
62
65
Error (w , http .StatusNotFound , err )
63
66
}
64
67
65
68
func PodNotFound (w http.ResponseWriter , name string , err error ) {
66
69
if ! errors .Is (err , define .ErrNoSuchPod ) {
67
70
InternalServerError (w , err )
71
+ return
68
72
}
69
73
Error (w , http .StatusNotFound , err )
70
74
}
71
75
72
76
func SessionNotFound (w http.ResponseWriter , name string , err error ) {
73
77
if ! errors .Is (err , define .ErrNoSuchExecSession ) {
74
78
InternalServerError (w , err )
79
+ return
75
80
}
76
81
Error (w , http .StatusNotFound , err )
77
82
}
78
83
79
84
func SecretNotFound (w http.ResponseWriter , nameOrID string , err error ) {
80
85
if errorhandling .Cause (err ).Error () != "no such secret" {
81
86
InternalServerError (w , err )
87
+ return
82
88
}
83
89
Error (w , http .StatusNotFound , err )
84
90
}
0 commit comments