github.com/ethersphere/bee/v2@v2.2.0/pkg/file/error.go (about) 1 // Copyright 2020 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package file 6 7 // AbortError should be returned whenever a file operation is terminated 8 // before it has completed. 9 type AbortError struct { 10 err error 11 } 12 13 // NewAbortError creates a new AbortError instance. 14 func NewAbortError(err error) error { 15 return &AbortError{ 16 err: err, 17 } 18 } 19 20 // Unwrap returns an underlying error. 21 func (e *AbortError) Unwrap() error { 22 return e.err 23 } 24 25 // Error implements standard go error interface. 26 func (e *AbortError) Error() string { 27 return e.err.Error() 28 } 29 30 // HashError should be returned whenever a file operation is terminated 31 // before it has completed. 32 type HashError struct { 33 err error 34 } 35 36 // NewHashError creates a new HashError instance. 37 func NewHashError(err error) error { 38 return &HashError{ 39 err: err, 40 } 41 } 42 43 // Unwrap returns an underlying error. 44 func (e *HashError) Unwrap() error { 45 return e.err 46 } 47 48 // Error implements standard go error interface. 49 func (e *HashError) Error() string { 50 return e.err.Error() 51 }