Skip to content

Commit

Permalink
Merge pull request #342 from teharrison/master
Browse files Browse the repository at this point in the history
more error text
  • Loading branch information
teharrison authored Apr 10, 2018
2 parents 16a664d + 51c05fc commit 053e7c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion shock-server/controller/node/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ func (cr *NodeController) Read(id string, ctx context.Context) error {
}
err = s.StreamSamtools(n.FilePath(), region, argv...)
if err != nil {
return responder.RespondWithError(ctx, http.StatusBadRequest, "error while invoking samtools")
err_msg := "err:@node_Read: " + err.Error()
logger.Error(err_msg)
return errors.New(err_msg)
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions shock-server/node/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type File struct {
type FileInfo struct {
R []SectionReader
E error
ESection int
Body io.ReadCloser
Name string
Size int64
Expand Down
17 changes: 10 additions & 7 deletions shock-server/request/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type MultiStreamer struct {
//type FileInfo struct {
// R []SectionReader
// E error
// ESection int
// Body io.ReadCloser
// Name string
// Size int64
Expand All @@ -39,12 +40,12 @@ type Streamer struct {
R []file.SectionReader
W http.ResponseWriter
E error
ESection int
ContentType string
Filename string
Size int64
Filter filter.FilterFunc
Compression string
Error error
}

// file.SectionReader interface required for MultiReaderAt
Expand Down Expand Up @@ -80,7 +81,7 @@ func (s *Streamer) Stream(streamRaw bool) (err error) {
pReader, pWriter := io.Pipe()
go func() {
defer pWriter.Close()
for _, sr := range s.R {
for i, sr := range s.R {
var rs io.Reader
if s.Filter != nil {
rs = s.Filter(sr)
Expand All @@ -90,14 +91,15 @@ func (s *Streamer) Stream(streamRaw bool) (err error) {
_, ioerr := io.Copy(pWriter, rs)
if ioerr != nil {
s.E = ioerr
s.ESection = i
return
}
}
}()

if s.E != nil {
pReader.Close()
err = fmt.Errorf("(request.Stream) failed: size=%s; file=%s; error=%s", s.Size, s.Filename, s.E.Error())
err = fmt.Errorf("(request.Stream: section %d) failed: raw=%t; size=%d; file=%s; error=%s", s.ESection, streamRaw, s.Size, s.Filename, s.E.Error())
return
}

Expand All @@ -109,7 +111,7 @@ func (s *Streamer) Stream(streamRaw bool) (err error) {
pReader.Close()

if ioerr != nil {
err = fmt.Errorf("(request.Stream) failed: size=%s; file=%s; error=%s", s.Size, s.Filename, ioerr.Error())
err = fmt.Errorf("(request.Stream: full stream) failed: raw=%t; size=%d; file=%s; error=%s", streamRaw, s.Size, s.Filename, ioerr.Error())
}
return
}
Expand All @@ -129,10 +131,11 @@ func (m *MultiStreamer) MultiStream() (err error) {
pReader, pWriter := io.Pipe()
f.Body = pReader
go func(lf *file.FileInfo) {
for _, sr := range lf.R {
for i, sr := range lf.R {
_, ioerr := io.Copy(pWriter, sr)
if ioerr != nil {
lf.E = ioerr
lf.ESection = i
}
}
pWriter.Close()
Expand All @@ -142,7 +145,7 @@ func (m *MultiStreamer) MultiStream() (err error) {
// identify any error files
for _, f := range m.Files {
if f.E != nil {
err = fmt.Errorf("(request.MultiStream) failed: size=%s; file=%s; error=%s", f.Size, f.Name, f.E.Error())
err = fmt.Errorf("(request.MultiStream: section %d) failed: size=%d; file=%s; error=%s", f.ESection, f.Size, f.Name, f.E.Error())
return
}
}
Expand All @@ -157,7 +160,7 @@ func (m *MultiStreamer) MultiStream() (err error) {
}

if ioerr != nil {
err = fmt.Errorf("(request.MultiStream) failed: file=%s; error=%s", m.Filename, ioerr.Error())
err = fmt.Errorf("(request.MultiStream: full stream) failed: file=%s; error=%s", m.Filename, ioerr.Error())
}
return
}
Expand Down

0 comments on commit 053e7c5

Please sign in to comment.