mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* first pass - working Signed-off-by: Joe Elliott <[email protected]> * refactor Signed-off-by: Joe Elliott <[email protected]> * working? Signed-off-by: Joe Elliott <[email protected]> * vendor Signed-off-by: Joe Elliott <[email protected]> * integration test Signed-off-by: Joe Elliott <[email protected]> * updated go.mod to latest Signed-off-by: Joe Elliott <[email protected]> * cleanup Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * lint Signed-off-by: Joe Elliott <[email protected]> * update servless mods Signed-off-by: Joe Elliott <[email protected]> * satisfy interface updates Signed-off-by: Joe Elliott <[email protected]> * lint Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]>
38 lines
678 B
Go
38 lines
678 B
Go
package cancellation
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
type cancellationError struct {
|
|
inner error
|
|
}
|
|
|
|
func NewError(err error) error {
|
|
return cancellationError{err}
|
|
}
|
|
|
|
func NewErrorf(format string, args ...any) error {
|
|
return NewError(fmt.Errorf(format, args...))
|
|
}
|
|
|
|
func (e cancellationError) Error() string {
|
|
return "context canceled: " + e.inner.Error()
|
|
}
|
|
|
|
func (e cancellationError) Is(err error) bool {
|
|
return err == context.Canceled
|
|
}
|
|
|
|
func (e cancellationError) Unwrap() error {
|
|
return e.inner
|
|
}
|
|
|
|
func (e cancellationError) GRPCStatus() *status.Status {
|
|
return status.New(codes.Canceled, e.Error())
|
|
}
|