diff --git a/chan.go b/chan.go index be0e8426..7bf83e7d 100644 --- a/chan.go +++ b/chan.go @@ -6,7 +6,6 @@ import ( "sync" "github.com/ipfs/go-ipfs-cmdkit" - "github.com/ipfs/go-ipfs-cmds/debug" ) func NewChanResponsePair(req *Request) (ResponseEmitter, Response) { @@ -130,12 +129,6 @@ func (re *chanResponseEmitter) Emit(v interface{}) error { re.wl.Lock() defer re.wl.Unlock() - // Initially this library allowed commands to return errors by sending an - // error value along a stream. We removed that in favour of CloseWithError, - // so we want to make sure we catch situations where some code still uses the - // old error emitting semantics and _panic_ in those situations. - debug.AssertNotError(v) - // unblock Length() select { case <-re.waitLen: diff --git a/cli/responseemitter.go b/cli/responseemitter.go index 3849be7b..6b882f04 100644 --- a/cli/responseemitter.go +++ b/cli/responseemitter.go @@ -9,7 +9,6 @@ import ( "syscall" "github.com/ipfs/go-ipfs-cmds" - "github.com/ipfs/go-ipfs-cmds/debug" ) var _ ResponseEmitter = &responseEmitter{} @@ -137,12 +136,6 @@ func (re *responseEmitter) Emit(v interface{}) error { isSingle = true } - // Initially this library allowed commands to return errors by sending an - // error value along a stream. We removed that in favour of CloseWithError, - // so we want to make sure we catch situations where some code still uses the - // old error emitting semantics and _panic_ in those situations. - debug.AssertNotError(v) - // channel emission iteration if ch, ok := v.(chan interface{}); ok { v = (<-chan interface{})(ch) diff --git a/debug/checkerr.go b/debug/checkerr.go deleted file mode 100644 index 0e35c932..00000000 --- a/debug/checkerr.go +++ /dev/null @@ -1,28 +0,0 @@ -package debug - -import ( - "fmt" - "runtime/debug" - - "github.com/ipfs/go-ipfs-cmdkit" -) - -// UnexpectedError wraps a *cmdkit.Error that is being emitted. That type (and its non-pointer version) used to be emitted to indicate an error. That was deprecated in favour of CloseWithError. -type UnexpectedError struct { - Err *cmdkit.Error -} - -// Error returns the error string -func (err UnexpectedError) Error() string { - return fmt.Sprintf("unexpected error value emitted: %q at\n%s", err.Err.Error(), debug.Stack()) -} - -// AssertNotError verifies that v is not a cmdkit.Error or *cmdkit.Error. Otherwise it panics. -func AssertNotError(v interface{}) { - if e, ok := v.(cmdkit.Error); ok { - v = &e - } - if e, ok := v.(*cmdkit.Error); ok { - panic(UnexpectedError{e}) - } -} diff --git a/http/responseemitter.go b/http/responseemitter.go index c5e478a3..163da4ae 100644 --- a/http/responseemitter.go +++ b/http/responseemitter.go @@ -10,7 +10,6 @@ import ( "github.com/ipfs/go-ipfs-cmdkit" cmds "github.com/ipfs/go-ipfs-cmds" - "github.com/ipfs/go-ipfs-cmds/debug" ) var ( @@ -88,12 +87,6 @@ type responseEmitter struct { } func (re *responseEmitter) Emit(value interface{}) error { - // Initially this library allowed commands to return errors by sending an - // error value along a stream. We removed that in favour of CloseWithError, - // so we want to make sure we catch situations where some code still uses the - // old error emitting semantics and _panic_ in those situations. - debug.AssertNotError(value) - // if we got a channel, instead emit values received on there. if ch, ok := value.(chan interface{}); ok { value = (<-chan interface{})(ch) diff --git a/writer.go b/writer.go index 6f5fcaad..4b6296f1 100644 --- a/writer.go +++ b/writer.go @@ -8,7 +8,6 @@ import ( "sync" "github.com/ipfs/go-ipfs-cmdkit" - "github.com/ipfs/go-ipfs-cmds/debug" ) func NewWriterResponseEmitter(w io.WriteCloser, req *Request) (ResponseEmitter, error) { @@ -154,14 +153,6 @@ func (re *writerResponseEmitter) Emit(v interface{}) error { return EmitChan(re, ch) } - // Initially this library allowed commands to return errors by sending an - // error value along a stream. We removed that in favour of CloseWithError, - // so we want to make sure we catch situations where some code still uses the - // old error emitting semantics. - // Also errors may occur both as pointers and as plain values, so we need to - // check both. - debug.AssertNotError(v) - if re.closed { return ErrClosedEmitter }