diff --git a/error.go b/error.go index 1d51c01..62c6cb2 100644 --- a/error.go +++ b/error.go @@ -63,6 +63,10 @@ func (e *ConnectionError) Timeout() bool { return false } +func (e *ConnectionError) Unwrap() error { + return e.error +} + // ContextError is returned when request has been ended with context timeout or cancel. type ContextError struct { error @@ -88,6 +92,10 @@ func (e *ContextError) Timeout() bool { return e.CtxErr == context.DeadlineExceeded } +func (e *ContextError) Unwrap() error { + return e.CtxErr +} + // QueryError is returned when query error has been happened. // It has error Code. type QueryError struct { @@ -113,6 +121,10 @@ func (e *QueryError) Timeout() bool { return false } +func (e *QueryError) Unwrap() error { + return e.error +} + // UnexpectedReplicaSetUUIDError is returned when ReplicaSetUUID set in Options.ReplicaSetUUID is not equal to ReplicaSetUUID // received during Join or JoinWithSnap. It is only an AnonSlave error! type UnexpectedReplicaSetUUIDError struct { @@ -136,6 +148,10 @@ func (e *UnexpectedReplicaSetUUIDError) Is(target error) bool { return ok } +func (e *UnexpectedReplicaSetUUIDError) Unwrap() error { + return e.QueryError +} + var _ Error = (*ConnectionError)(nil) var _ Error = (*QueryError)(nil) var _ Error = (*ContextError)(nil)