storj/private/readcloser/fatal.go
2019-11-14 21:46:15 +02:00

24 lines
449 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package readcloser
import "io"
// FatalReadCloser returns a ReadCloser that always fails with err.
func FatalReadCloser(err error) io.ReadCloser {
return &fatalReadCloser{Err: err}
}
type fatalReadCloser struct {
Err error
}
func (f *fatalReadCloser) Read(p []byte) (n int, err error) {
return 0, f.Err
}
func (f *fatalReadCloser) Close() error {
return nil
}