github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/model/model.go (about) 1 package model 2 3 import "errors" 4 5 type NotFoundError struct{ Err error } 6 7 func (e NotFoundError) Error() string { return e.Err.Error() } 8 9 func (e NotFoundError) Unwrap() error { return e.Err } 10 11 func IsNotFoundError(err error) bool { 12 if err == nil { 13 return false 14 } 15 var v NotFoundError 16 return errors.As(err, &v) 17 } 18 19 type ValidationError struct{ Err error } 20 21 func (e ValidationError) Error() string { return e.Err.Error() } 22 23 func (e ValidationError) Unwrap() error { return e.Err } 24 25 func IsValidationError(err error) bool { 26 if err == nil { 27 return false 28 } 29 var v ValidationError 30 return errors.As(err, &v) 31 } 32 33 type AuthenticationError struct{ Err error } 34 35 func (e AuthenticationError) Error() string { return e.Err.Error() } 36 37 func (e AuthenticationError) Unwrap() error { return e.Err } 38 39 func IsAuthenticationError(err error) bool { 40 if err == nil { 41 return false 42 } 43 var v AuthenticationError 44 return errors.As(err, &v) 45 } 46 47 type AuthorizationError struct{ Err error } 48 49 func (e AuthorizationError) Error() string { return e.Err.Error() } 50 51 func (e AuthorizationError) Unwrap() error { return e.Err } 52 53 func IsAuthorizationError(err error) bool { 54 if err == nil { 55 return false 56 } 57 var v AuthorizationError 58 return errors.As(err, &v) 59 } 60 61 func String(s string) *string { return &s }