The "param" field was only used to generate the error-message, and the
produced error-message was missing a space so we may as well just inline it.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -114,16 +114,6 @@ type ArchiveOptions struct {
|
| 114 | 114 |
Path string |
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 |
-type badParameterError struct {
|
|
| 118 |
- param string |
|
| 119 |
-} |
|
| 120 |
- |
|
| 121 |
-func (e badParameterError) Error() string {
|
|
| 122 |
- return "bad parameter: " + e.param + "cannot be empty" |
|
| 123 |
-} |
|
| 124 |
- |
|
| 125 |
-func (e badParameterError) InvalidParameter() {}
|
|
| 126 |
- |
|
| 127 | 117 |
// ArchiveFormValues parses form values and turns them into ArchiveOptions. |
| 128 | 118 |
// It fails if the archive name and path are not in the request. |
| 129 | 119 |
func ArchiveFormValues(r *http.Request, vars map[string]string) (ArchiveOptions, error) {
|
| ... | ... |
@@ -133,11 +123,11 @@ func ArchiveFormValues(r *http.Request, vars map[string]string) (ArchiveOptions, |
| 133 | 133 |
|
| 134 | 134 |
name := vars["name"] |
| 135 | 135 |
if name == "" {
|
| 136 |
- return ArchiveOptions{}, badParameterError{"name"}
|
|
| 136 |
+ return ArchiveOptions{}, errdefs.InvalidParameter(errors.New("bad parameter: name cannot be empty"))
|
|
| 137 | 137 |
} |
| 138 | 138 |
path := r.Form.Get("path")
|
| 139 | 139 |
if path == "" {
|
| 140 |
- return ArchiveOptions{}, badParameterError{"path"}
|
|
| 140 |
+ return ArchiveOptions{}, errdefs.InvalidParameter(errors.New("bad parameter: path cannot be empty"))
|
|
| 141 | 141 |
} |
| 142 | 142 |
return ArchiveOptions{name, path}, nil
|
| 143 | 143 |
} |