本文整理汇总了Golang中github.com/piotrkowalczuk/sklog.NewContextErrorGeneric函数的典型用法代码示例。如果您正苦于以下问题:Golang NewContextErrorGeneric函数的具体用法?Golang NewContextErrorGeneric怎么用?Golang NewContextErrorGeneric使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewContextErrorGeneric函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:8,代码来源:context.go
示例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)
}
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:28,代码来源:context.go
示例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,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:8,代码来源:context.go
示例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,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:9,代码来源:context.go
示例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,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:14,代码来源:context.go
示例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,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:7,代码来源:context.go
示例7: NewContextJSONSyntaxError
// NewContextJSONSyntaxError ...
func NewContextJSONSyntaxError(logger log.Logger, e *json.SyntaxError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_offset", e.Offset,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例8: NewContextJSONInvalidUTF8Error
// NewContextJSONInvalidUTF8Error ...
func NewContextJSONInvalidUTF8Error(logger log.Logger, e *json.InvalidUTF8Error) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_s", e.S,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例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,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:7,代码来源:context.go
示例10: NewContextJSONUnsupportedTypeError
// NewContextJSONUnsupportedTypeError ...
func NewContextJSONUnsupportedTypeError(logger log.Logger, e *json.UnsupportedTypeError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_type", e.Type,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例11: NewContextJSONInvalidUnmarshalError
// NewContextJSONInvalidUnmarshalError ...
func NewContextJSONInvalidUnmarshalError(logger log.Logger, e *json.InvalidUnmarshalError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_type", e.Type,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例12: NewContextJSONMarshalerError
// NewContextJSONMarshalerError ...
func NewContextJSONMarshalerError(logger log.Logger, e *json.MarshalerError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"json_type", e.Type,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例13: NewContextScannerError
// NewContextScannerError ...
func NewContextScannerError(logger log.Logger, e *scanner.Error) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"scanner_pos", e.Pos,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例14: NewContextOSSyscallError
// NewContextOSSyscallError ...
func NewContextOSSyscallError(logger log.Logger, e *os.SyscallError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"os_syscall", e.Syscall,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例15: NewContextTextProtoError
// NewContextTextProtoError ...
func NewContextTextProtoError(logger log.Logger, e *textproto.Error) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"textproto_code", e.Code,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:6,代码来源:context.go
示例16: NewContextQueryError
// NewContextQueryError ...
func NewContextQueryError(logger log.Logger, err *mgo.QueryError) *log.Context {
return sklog.NewContextErrorGeneric(logger, err).With(
"mgo_query_code", err.Code,
"mgo_query_assertion", err.Assertion,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:7,代码来源:context.go
示例17: NewContextReflectValueError
// NewContextReflectValueError ...
func NewContextReflectValueError(logger log.Logger, e *reflect.ValueError) *log.Context {
return sklog.NewContextErrorGeneric(logger, e).With(
"reflect_kind", e.Kind,
"reflect_method", e.Method,
)
}
开发者ID:piotrkowalczuk,项目名称:sklog,代码行数:7,代码来源:context.go
注:本文中的github.com/piotrkowalczuk/sklog.NewContextErrorGeneric函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论