本文整理汇总了Golang中github.com/piotrkowalczuk/sklog.NewContextErrorGeneric函数的典型用法代码示例。如果您正苦于以下问题:Golang NewContextErrorGeneric函数的具体用法?Golang NewContextErrorGeneric怎么用?Golang NewContextErrorGeneric使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewContextErrorGeneric函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewContextErrorGeneric
// NewContextErrorGeneric ...
func NewContextErrorGeneric(logger log.Logger, err error) *log.Context {
if pqe, ok := err.(*pq.Error); ok {
return NewContextError(logger, pqe)
}
return sklog.NewContextErrorGeneric(logger, err)
}
示例2: NewContextError
// NewContextErrorGeneric creates context for given error.
// Performs error type check internally to choose strategy that fits the best.
func NewContextError(logger log.Logger, err error) *log.Context {
if ctx, ok := err.(sklog.Contexter); ok {
return log.NewContext(logger).With(ctx.Context())
}
switch e := err.(type) {
case *json.MarshalerError:
return NewContextJSONMarshalerError(logger, e)
case *json.InvalidUnmarshalError:
return NewContextJSONInvalidUnmarshalError(logger, e)
case *json.UnmarshalFieldError:
return NewContextJSONUnmarshalFieldError(logger, e)
case *json.UnmarshalTypeError:
return NewContextJSONUnmarshalTypeError(logger, e)
case *json.UnsupportedTypeError:
return NewContextJSONUnsupportedTypeError(logger, e)
case *json.UnsupportedValueError:
return NewContextJSONUnsupportedValueError(logger, e)
case *json.InvalidUTF8Error:
return NewContextJSONInvalidUTF8Error(logger, e)
case *json.SyntaxError:
return NewContextJSONSyntaxError(logger, e)
default:
return sklog.NewContextErrorGeneric(logger, e)
}
}
示例3: NewContextJSONUnmarshalTypeError
// NewContextJSONUnmarshalTypeError ...
func NewContextJSONUnmarshalTypeError(logger log.Logger, e *json.UnmarshalTypeError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_type", e.Type,
"json_offset", e.Offset,
"json_value", e.Value,
)
}
示例4: NewContextNetOpError
// NewContextNetOpError ...
func NewContextNetOpError(logger log.Logger, e *net.OpError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"net_addr", e.Addr,
"net_net", e.Net,
"net_op", e.Op,
"net_source", e.Source,
)
}
示例5: NewContextJSONUnmarshalFieldError
// NewContextJSONUnmarshalFieldError ...
func NewContextJSONUnmarshalFieldError(logger log.Logger, e *json.UnmarshalFieldError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_key", e.Key,
"json_type", e.Type,
"json_field_name", e.Field.Name,
"json_field_pkg_path", e.Field.PkgPath,
"json_field_type", e.Field.Type,
"json_field_tag", e.Field.Tag,
"json_field_offset", e.Field.Offset,
"json_field_index", e.Field.Index,
"json_field_anonymous", e.Field.Anonymous,
)
}
示例6: NewContextOSPathError
// NewContextOSPathError ...
func NewContextOSPathError(logger log.Logger, e *os.PathError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"os_op", e.Op,
"os_path", e.Path,
)
}
示例7: NewContextJSONSyntaxError
// NewContextJSONSyntaxError ...
func NewContextJSONSyntaxError(logger log.Logger, e *json.SyntaxError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_offset", e.Offset,
)
}
示例8: NewContextJSONInvalidUTF8Error
// NewContextJSONInvalidUTF8Error ...
func NewContextJSONInvalidUTF8Error(logger log.Logger, e *json.InvalidUTF8Error) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_s", e.S,
)
}
示例9: NewContextJSONUnsupportedValueError
// NewContextJSONUnsupportedValueError ...
func NewContextJSONUnsupportedValueError(logger log.Logger, e *json.UnsupportedValueError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_value", e.Value,
"json_str", e.Str,
)
}
示例10: NewContextJSONUnsupportedTypeError
// NewContextJSONUnsupportedTypeError ...
func NewContextJSONUnsupportedTypeError(logger log.Logger, e *json.UnsupportedTypeError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_type", e.Type,
)
}
示例11: NewContextJSONInvalidUnmarshalError
// NewContextJSONInvalidUnmarshalError ...
func NewContextJSONInvalidUnmarshalError(logger log.Logger, e *json.InvalidUnmarshalError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_type", e.Type,
)
}
示例12: NewContextJSONMarshalerError
// NewContextJSONMarshalerError ...
func NewContextJSONMarshalerError(logger log.Logger, e *json.MarshalerError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_type", e.Type,
)
}
示例13: NewContextScannerError
// NewContextScannerError ...
func NewContextScannerError(logger log.Logger, e *scanner.Error) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"scanner_pos", e.Pos,
)
}
示例14: NewContextOSSyscallError
// NewContextOSSyscallError ...
func NewContextOSSyscallError(logger log.Logger, e *os.SyscallError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"os_syscall", e.Syscall,
)
}
示例15: NewContextTextProtoError
// NewContextTextProtoError ...
func NewContextTextProtoError(logger log.Logger, e *textproto.Error) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"textproto_code", e.Code,
)
}