diff --git a/peer/http3/store.go b/peer/http3/store.go index 2d9a23c..f842437 100644 --- a/peer/http3/store.go +++ b/peer/http3/store.go @@ -13,6 +13,9 @@ import ( "github.com/lucas-clemente/quic-go/http3" ) +//ErrNotImplemented is a standard error when a store that implements the store interface does not implement a method +var ErrNotImplemented = errors.Base("this store does not implement this method") + // Store is a blob store that gets blobs from a peer. // It satisfies the store.BlobStore interface but cannot put or delete blobs. type Store struct { @@ -81,17 +84,17 @@ func (p *Store) Get(hash string) (stream.Blob, shared.BlobTrace, error) { // Put is not supported func (p *Store) Put(hash string, blob stream.Blob) error { - panic("http3Store cannot put or delete blobs") + return errors.Err(ErrNotImplemented) } // PutSD is not supported func (p *Store) PutSD(hash string, blob stream.Blob) error { - panic("http3Store cannot put or delete blobs") + return errors.Err(ErrNotImplemented) } // Delete is not supported func (p *Store) Delete(hash string) error { - panic("http3Store cannot put or delete blobs") + return errors.Err(ErrNotImplemented) } // Delete is not supported diff --git a/peer/store.go b/peer/store.go index c227884..6bf3b38 100644 --- a/peer/store.go +++ b/peer/store.go @@ -8,6 +8,9 @@ import ( "github.com/lbryio/reflector.go/shared" ) +//ErrNotImplemented is a standard error when a store that implements the store interface does not implement a method +var ErrNotImplemented = errors.Base("this store does not implement this method") + // Store is a blob store that gets blobs from a peer. // It satisfies the store.BlobStore interface but cannot put or delete blobs. type Store struct { @@ -56,17 +59,17 @@ func (p *Store) Get(hash string) (stream.Blob, shared.BlobTrace, error) { // Put is not supported func (p *Store) Put(hash string, blob stream.Blob) error { - panic("PeerStore cannot put or delete blobs") + return errors.Err(ErrNotImplemented) } // PutSD is not supported func (p *Store) PutSD(hash string, blob stream.Blob) error { - panic("PeerStore cannot put or delete blobs") + return errors.Err(ErrNotImplemented) } // Delete is not supported func (p *Store) Delete(hash string) error { - panic("PeerStore cannot put or delete blobs") + return errors.Err(ErrNotImplemented) } // Delete is not supported diff --git a/store/cloudfront_ro.go b/store/cloudfront_ro.go index 51fe4b8..fcc8ed0 100644 --- a/store/cloudfront_ro.go +++ b/store/cloudfront_ro.go @@ -93,15 +93,15 @@ func (c *CloudFrontROStore) cfRequest(method, hash string) (int, io.ReadCloser, } func (c *CloudFrontROStore) Put(_ string, _ stream.Blob) error { - panic("CloudFrontROStore cannot do writes. Use CloudFrontRWStore") + return errors.Err(ErrNotImplemented) } func (c *CloudFrontROStore) PutSD(_ string, _ stream.Blob) error { - panic("CloudFrontROStore cannot do writes. Use CloudFrontRWStore") + return errors.Err(ErrNotImplemented) } func (c *CloudFrontROStore) Delete(_ string) error { - panic("CloudFrontROStore cannot do writes. Use CloudFrontRWStore") + return errors.Err(ErrNotImplemented) } // Shutdown shuts down the store gracefully diff --git a/store/store.go b/store/store.go index bd9223b..3a2fc6f 100644 --- a/store/store.go +++ b/store/store.go @@ -40,3 +40,6 @@ type lister interface { //ErrBlobNotFound is a standard error when a blob is not found in the store. var ErrBlobNotFound = errors.Base("blob not found") + +//ErrNotImplemented is a standard error when a store that implements this interface does not implement a method +var ErrNotImplemented = errors.Base("this store does not implement this method")