summaryrefslogtreecommitdiff
path: root/vendor/github.com/uber/jaeger-client-go/thrift/protocol_exception.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/uber/jaeger-client-go/thrift/protocol_exception.go')
-rw-r--r--vendor/github.com/uber/jaeger-client-go/thrift/protocol_exception.go44
1 files changed, 35 insertions, 9 deletions
diff --git a/vendor/github.com/uber/jaeger-client-go/thrift/protocol_exception.go b/vendor/github.com/uber/jaeger-client-go/thrift/protocol_exception.go
index 6e357ee89..9dcf4bfd9 100644
--- a/vendor/github.com/uber/jaeger-client-go/thrift/protocol_exception.go
+++ b/vendor/github.com/uber/jaeger-client-go/thrift/protocol_exception.go
@@ -21,6 +21,7 @@ package thrift
import (
"encoding/base64"
+ "errors"
)
// Thrift Protocol exception
@@ -40,8 +41,15 @@ const (
)
type tProtocolException struct {
- typeId int
- message string
+ typeId int
+ err error
+ msg string
+}
+
+var _ TProtocolException = (*tProtocolException)(nil)
+
+func (tProtocolException) TExceptionType() TExceptionType {
+ return TExceptionTypeProtocol
}
func (p *tProtocolException) TypeId() int {
@@ -49,30 +57,48 @@ func (p *tProtocolException) TypeId() int {
}
func (p *tProtocolException) String() string {
- return p.message
+ return p.msg
}
func (p *tProtocolException) Error() string {
- return p.message
+ return p.msg
+}
+
+func (p *tProtocolException) Unwrap() error {
+ return p.err
}
func NewTProtocolException(err error) TProtocolException {
if err == nil {
return nil
}
- if e,ok := err.(TProtocolException); ok {
+
+ if e, ok := err.(TProtocolException); ok {
return e
}
- if _, ok := err.(base64.CorruptInputError); ok {
- return &tProtocolException{INVALID_DATA, err.Error()}
+
+ if errors.As(err, new(base64.CorruptInputError)) {
+ return NewTProtocolExceptionWithType(INVALID_DATA, err)
}
- return &tProtocolException{UNKNOWN_PROTOCOL_EXCEPTION, err.Error()}
+
+ return NewTProtocolExceptionWithType(UNKNOWN_PROTOCOL_EXCEPTION, err)
}
func NewTProtocolExceptionWithType(errType int, err error) TProtocolException {
if err == nil {
return nil
}
- return &tProtocolException{errType, err.Error()}
+ return &tProtocolException{
+ typeId: errType,
+ err: err,
+ msg: err.Error(),
+ }
}
+func prependTProtocolException(prepend string, err TProtocolException) TProtocolException {
+ return &tProtocolException{
+ typeId: err.TypeId(),
+ err: err,
+ msg: prepend + err.Error(),
+ }
+}