github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/xcontext/context_error.go (about) 1 package xcontext 2 3 import ( 4 "github.com/ydb-platform/ydb-go-sdk/v3/internal/stack" 5 ) 6 7 var _ error = (*ctxError)(nil) 8 9 const ( 10 atWord = "at" 11 fromWord = "from" 12 ) 13 14 func errAt(err error, skipDepth int) error { 15 return &ctxError{ 16 err: err, 17 stackRecord: stack.Record(skipDepth + 1), 18 linkWord: atWord, 19 } 20 } 21 22 func errFrom(err error, from string) error { 23 return &ctxError{ 24 err: err, 25 stackRecord: from, 26 linkWord: fromWord, 27 } 28 } 29 30 type ctxError struct { 31 err error 32 stackRecord string 33 linkWord string 34 } 35 36 func (e *ctxError) Error() string { 37 return "'" + e.err.Error() + "' " + e.linkWord + " `" + e.stackRecord + "`" 38 } 39 40 func (e *ctxError) Unwrap() error { 41 return e.err 42 }