forked from sourcenetwork/defradb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Extract inline (http and client) errors to errors.go (sourcene…
…twork#967) * Move unexpected type error to client * Make existing http errors public * Extract http errors to errors.go * Extract some cli errors * Extract client errors
- Loading branch information
1 parent
a00f3c0
commit 6a4a25f
Showing
17 changed files
with
167 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package cli | ||
|
||
import "github.com/sourcenetwork/defradb/errors" | ||
|
||
const ( | ||
errMissingArg string = "missing arguement" | ||
errMissingArgs string = "missing arguements" | ||
errFailedToCreateRPCClient string = "failed to create RPC client" | ||
errFailedToAddReplicator string = "failed to add replicator, request failed" | ||
errFailedToJoinEndpoint string = "failed to join endpoint" | ||
errFailedToSendRequest string = "failed to send request" | ||
errFailedToReadResponseBody string = "failed to read response body" | ||
errFailedToStatStdOut string = "failed to stat stdout" | ||
errFailedToHandleGQLErrors string = "failed to handle GraphQL errors" | ||
errFailedToPrettyPrintResponse string = "failed to pretty print response" | ||
) | ||
|
||
// Errors returnable from this package. | ||
// | ||
// This list is incomplete and undefined errors may also be returned. | ||
// Errors returned from this package may be tested against these errors with errors.Is. | ||
var ( | ||
ErrMissingArg = errors.New(errMissingArg) | ||
ErrMissingArgs = errors.New(errMissingArgs) | ||
ErrFailToWrapRPCClient = errors.New(errFailedToCreateRPCClient) | ||
ErrFailedToAddReplicator = errors.New(errFailedToAddReplicator) | ||
ErrFailedToJoinEndpoint = errors.New(errFailedToJoinEndpoint) | ||
ErrFailedToSendRequest = errors.New(errFailedToSendRequest) | ||
ErrFailedToReadResponseBody = errors.New(errFailedToReadResponseBody) | ||
ErrFailedToStatStdOut = errors.New(errFailedToStatStdOut) | ||
ErrFailedToHandleGQLErrors = errors.New(errFailedToHandleGQLErrors) | ||
ErrFailedToPrettyPrintResponse = errors.New(errFailedToPrettyPrintResponse) | ||
) | ||
|
||
func NewErrMissingArg(name string) error { | ||
return errors.New(errMissingArg, errors.NewKV("Name", name)) | ||
} | ||
|
||
func NewErrMissingArgs(count int, provided int) error { | ||
return errors.New(errMissingArgs, errors.NewKV("Required", count), errors.NewKV("Provided", provided)) | ||
} | ||
|
||
func NewErrFailedToCreateRPCClient(inner error) error { | ||
return errors.Wrap(errFailedToCreateRPCClient, inner) | ||
} | ||
|
||
func NewErrFailedToAddReplicator(inner error) error { | ||
return errors.Wrap(errFailedToAddReplicator, inner) | ||
} | ||
|
||
func NewErrFailedToJoinEndpoint(inner error) error { | ||
return errors.Wrap(errFailedToJoinEndpoint, inner) | ||
} | ||
|
||
func NewErrFailedToSendRequest(inner error) error { | ||
return errors.Wrap(errFailedToSendRequest, inner) | ||
} | ||
|
||
func NewErrFailedToReadResponseBody(inner error) error { | ||
return errors.Wrap(errFailedToReadResponseBody, inner) | ||
} | ||
|
||
func NewErrFailedToStatStdOut(inner error) error { | ||
return errors.Wrap(errFailedToStatStdOut, inner) | ||
} | ||
|
||
func NewErrFailedToHandleGQLErrors(inner error) error { | ||
return errors.Wrap(errFailedToHandleGQLErrors, inner) | ||
} | ||
|
||
func NewErrFailedToPrettyPrintResponse(inner error) error { | ||
return errors.Wrap(errFailedToPrettyPrintResponse, inner) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.