storj/internal/pkg/readcloser/fatal.go
Kaloyan Raev f96cc9c955 HTTP Ranger (#11)
* HTTPRanger

* Migrate eestream library to use ReadCloser instead of Reader

* Use MultiReadCloser instead of MultiReader

* Adapt example cli cmds to latest serverbox changes

* Close LazyReadCloser only if only generated

* Close ReadClosers sequentially

* Close response body on unexpected status code

* Avoid double close of the pipe reader

* Better formatting for imports

* Exit instead of panicking
2018-04-17 07:39:14 -06:00

24 lines
449 B
Go

// Copyright (C) 2018 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
}