mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
Remove github.com/pkg/errors and replace with std library version
This is possible now that we no longer support go1.12 and brings rclone into line with standard practices in the Go world. This also removes errors.New and errors.Errorf from lib/errors and prefers the stdlib errors package over lib/errors.
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/accounting"
|
||||
"github.com/rclone/rclone/fs/config/configfile"
|
||||
@@ -91,23 +90,23 @@ func RPC(method string, input string) (output string, status int) {
|
||||
// create a buffer to capture the output
|
||||
err := json.NewDecoder(strings.NewReader(input)).Decode(&in)
|
||||
if err != nil {
|
||||
return writeError(method, in, errors.Wrap(err, "failed to read input JSON"), http.StatusBadRequest)
|
||||
return writeError(method, in, fmt.Errorf("failed to read input JSON: %w", err), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// Find the call
|
||||
call := rc.Calls.Get(method)
|
||||
if call == nil {
|
||||
return writeError(method, in, errors.Errorf("couldn't find method %q", method), http.StatusNotFound)
|
||||
return writeError(method, in, fmt.Errorf("couldn't find method %q", method), http.StatusNotFound)
|
||||
}
|
||||
|
||||
// TODO: handle these cases
|
||||
if call.NeedsRequest {
|
||||
return writeError(method, in, errors.Errorf("method %q needs request, not supported", method), http.StatusNotFound)
|
||||
return writeError(method, in, fmt.Errorf("method %q needs request, not supported", method), http.StatusNotFound)
|
||||
// Add the request to RC
|
||||
//in["_request"] = r
|
||||
}
|
||||
if call.NeedsResponse {
|
||||
return writeError(method, in, errors.Errorf("method %q need response, not supported", method), http.StatusNotFound)
|
||||
return writeError(method, in, fmt.Errorf("method %q need response, not supported", method), http.StatusNotFound)
|
||||
//in["_response"] = w
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user