diff --git a/changelog/unreleased/fix-missing-statuscode.md b/changelog/unreleased/fix-missing-statuscode.md new file mode 100644 index 0000000000..01212f22a5 --- /dev/null +++ b/changelog/unreleased/fix-missing-statuscode.md @@ -0,0 +1,5 @@ +Bugfix: Add missing http status code + +This Fix adds a missing status code to the InsufficientStorage error in reva, to allow tus to pass it through. + +https://github.com/cs3org/reva/pull/2891 diff --git a/pkg/errtypes/errtypes.go b/pkg/errtypes/errtypes.go index 14d18f744c..95cf3a5f5e 100644 --- a/pkg/errtypes/errtypes.go +++ b/pkg/errtypes/errtypes.go @@ -145,9 +145,19 @@ func (e InsufficientStorage) Error() string { return "error: insufficient storag // IsInsufficientStorage implements the IsInsufficientStorage interface. func (e InsufficientStorage) IsInsufficientStorage() {} -// StatusInssufficientStorage 507 is an official http status code to indicate that there is insufficient storage +// StatusCode returns StatusInsufficientStorage, this implementation is needed to allow TUS to cast the correct http errors. +func (e InsufficientStorage) StatusCode() int { + return StatusInsufficientStorage +} + +// Body returns the error body. This implementation is needed to allow TUS to cast the correct http errors +func (e InsufficientStorage) Body() []byte { + return []byte(e.Error()) +} + +// StatusInsufficientStorage 507 is an official HTTP status code to indicate that there is insufficient storage // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507 -const StatusInssufficientStorage = 507 +const StatusInsufficientStorage = 507 // IsNotFound is the interface to implement // to specify that an a resource is not found.