error.go 1.09 KB
Newer Older
1 2 3 4 5 6
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package file

7
// AbortError should be returned whenever a file operation is terminated
8 9 10 11 12
// before it has completed.
type AbortError struct {
	err error
}

13
// NewAbortError creates a new AbortError instance.
14 15 16 17 18 19 20 21 22 23 24
func NewAbortError(err error) error {
	return &AbortError{
		err: err,
	}
}

// Unwrap returns an underlying error.
func (e *AbortError) Unwrap() error {
	return e.err
}

25
// Error implements standard go error interface.
26 27 28
func (e *AbortError) Error() string {
	return e.err.Error()
}
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

// HashError should be returned whenever a file operation is terminated
// before it has completed.
type HashError struct {
	err error
}

// NewHashError creates a new HashError instance.
func NewHashError(err error) error {
	return &HashError{
		err: err,
	}
}

// Unwrap returns an underlying error.
func (e *HashError) Unwrap() error {
	return e.err
}

48
// Error implements standard go error interface.
49 50 51
func (e *HashError) Error() string {
	return e.err.Error()
}