-
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.
fix: remove generic failure type (#12)
resolves #5
- Loading branch information
Showing
3 changed files
with
62 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
package storage | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/storacha/go-ucanto/ucan" | ||
) | ||
|
||
type UnsupportedCapabilityError[C any] struct { | ||
capability ucan.Capability[C] | ||
} | ||
|
||
func (ue UnsupportedCapabilityError[C]) Name() string { | ||
return "UnsupportedCapability" | ||
} | ||
|
||
func (ue UnsupportedCapabilityError[C]) Capability() ucan.Capability[C] { | ||
return ue.capability | ||
} | ||
|
||
func (ue UnsupportedCapabilityError[C]) Error() string { | ||
return fmt.Sprintf(`%s does not have a "%s" capability provider`, ue.capability.With(), ue.capability.Can()) | ||
} | ||
|
||
func NewUnsupportedCapabilityError[C any](capability ucan.Capability[C]) UnsupportedCapabilityError[C] { | ||
return UnsupportedCapabilityError[C]{capability} | ||
} | ||
|
||
type BlobSizeLimitExceededError struct { | ||
size uint64 | ||
max uint64 | ||
} | ||
|
||
func (be BlobSizeLimitExceededError) Name() string { | ||
return "BlobSizeOutsideOfSupportedRange" | ||
} | ||
|
||
func (be BlobSizeLimitExceededError) Error() string { | ||
return fmt.Sprintf("Blob of %d bytes, exceeds size limit of %d bytes", be.size, be.max) | ||
} | ||
|
||
func NewBlobSizeLimitExceededError(size uint64, max uint64) BlobSizeLimitExceededError { | ||
return BlobSizeLimitExceededError{size, max} | ||
} | ||
|
||
type AllocatedMemoryNotWrittenError struct{} | ||
|
||
func (ae AllocatedMemoryNotWrittenError) Name() string { | ||
return "AllocatedMemoryHadNotBeenWrittenTo" | ||
} | ||
|
||
func (ae AllocatedMemoryNotWrittenError) Error() string { | ||
return "Blob not found" | ||
} | ||
|
||
func NewAllocatedMemoryNotWrittenError() AllocatedMemoryNotWrittenError { | ||
return AllocatedMemoryNotWrittenError{} | ||
} |
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