mirror of
https://github.com/alexgo-io/gaze-indexer.git
synced 2026-04-29 04:05:12 +08:00
Merge branch 'feature/bitcoin-indexer' of github.com:gaze-network/indexer-network into feature/bitcoin-indexer
This commit is contained in:
@@ -79,6 +79,9 @@ linters-settings:
|
||||
- .WithMessage(
|
||||
- .WithMessagef(
|
||||
- .WithStack(
|
||||
- errs.NewPublicError(
|
||||
- errs.WithPublicMessage(
|
||||
- withstack.WithStackDepth(
|
||||
ignoreSigRegexps:
|
||||
- \.New.*Error\(
|
||||
goconst:
|
||||
|
||||
30
common/errs/public_errs.go
Normal file
30
common/errs/public_errs.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package errs
|
||||
|
||||
import (
|
||||
"github.com/cockroachdb/errors"
|
||||
"github.com/cockroachdb/errors/withstack"
|
||||
)
|
||||
|
||||
type PublicError struct {
|
||||
err error
|
||||
message string
|
||||
}
|
||||
|
||||
func (p PublicError) Error() string {
|
||||
return p.err.Error()
|
||||
}
|
||||
|
||||
func (p PublicError) Message() string {
|
||||
return p.message
|
||||
}
|
||||
|
||||
func NewPublicError(message string) error {
|
||||
return withstack.WithStackDepth(&PublicError{err: errors.New(message), message: message}, 1)
|
||||
}
|
||||
|
||||
func WithPublicMessage(err error, message string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return withstack.WithStackDepth(&PublicError{err: err, message: message}, 1)
|
||||
}
|
||||
Reference in New Issue
Block a user