Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace particular request not found errors with public error #188

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions graphsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ func (e RequestCancelledErr) Error() string {
return "Request Failed - Responder Cancelled"
}

// RequestNotFoundErr indicates that a request with a particular request ID was not found
type RequestNotFoundErr struct{}

func (e RequestNotFoundErr) Error() string {
return "request not found"
}

masih marked this conversation as resolved.
Show resolved Hide resolved
var (
// ErrExtensionAlreadyRegistered means a user extension can be registered only once
ErrExtensionAlreadyRegistered = errors.New("extension already registered")
Expand Down
6 changes: 3 additions & 3 deletions requestmanager/requestmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (crm *cancelRequestMessage) handle(rm *RequestManager) {
if !ok {
if crm.onTerminated != nil {
select {
case crm.onTerminated <- errors.New("request not found"):
case crm.onTerminated <- graphsync.RequestNotFoundErr{}:
case <-rm.ctx.Done():
}
}
Expand Down Expand Up @@ -659,7 +659,7 @@ func (rm *RequestManager) sendRequest(p peer.ID, request gsmsg.GraphSyncRequest)
func (urm *unpauseRequestMessage) unpause(rm *RequestManager) error {
inProgressRequestStatus, ok := rm.inProgressRequestStatuses[urm.id]
if !ok {
return errors.New("request not found")
return graphsync.RequestNotFoundErr{}
}
if !inProgressRequestStatus.paused {
return errors.New("request is not paused")
Expand All @@ -685,7 +685,7 @@ func (urm *unpauseRequestMessage) handle(rm *RequestManager) {
func (prm *pauseRequestMessage) pause(rm *RequestManager) error {
inProgressRequestStatus, ok := rm.inProgressRequestStatuses[prm.id]
if !ok {
return errors.New("request not found")
return graphsync.RequestNotFoundErr{}
}
if inProgressRequestStatus.paused {
return errors.New("request is already paused")
Expand Down