parent
e17f3995fa
commit
15852b0712
@ -0,0 +1,57 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name fomat_builder.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
import "time"
|
||||
|
||||
type (
|
||||
|
||||
FormatBuilder interface {
|
||||
Options() FormatOps
|
||||
|
||||
Reset ()
|
||||
|
||||
Level () int
|
||||
Error () error
|
||||
Bytes () []byte
|
||||
|
||||
AddError (err error, options ...FormatOpsFnc)
|
||||
AddCause (err error, options ...FormatOpsFnc)
|
||||
|
||||
AddType (ter string, options ...FormatOpsFnc)
|
||||
|
||||
//AddTrace (trace StackTrace, options ...FormatOpsFnc)
|
||||
|
||||
AddString (str string, options ...FormatOpsFnc)
|
||||
AddStringLn (str string, options ...FormatOpsFnc)
|
||||
|
||||
AddFieldString (name string, value string , options ...FormatOpsFnc)
|
||||
AddFieldInt (name string, value int , options ...FormatOpsFnc)
|
||||
AddFieldFloat (name string, value float64 , options ...FormatOpsFnc)
|
||||
AddFieldTime (name string, value time.Time, options ...FormatOpsFnc)
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name error_formattable_options.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
FormatOps struct {
|
||||
FormatShow
|
||||
Indent string
|
||||
Color FormatColor
|
||||
FieldNameColor FormatColor
|
||||
FieldValueColor FormatColor
|
||||
|
||||
FieldNameAdapter func(string) string
|
||||
}
|
||||
|
||||
FormatOpsFnc func (ops *FormatOps)
|
||||
)
|
||||
|
||||
|
||||
|
||||
func (o *FormatOps) Clone (options ...FormatOpsFnc) *FormatOps {
|
||||
if len(options) == 0 {
|
||||
return o
|
||||
}
|
||||
no := *o
|
||||
for _,op := range options {
|
||||
op(&no)
|
||||
}
|
||||
return &no
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name format_use_ops.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
|
||||
|
||||
const (
|
||||
|
||||
FormatShowType FormatShow = 1 << iota
|
||||
FormatShowColors
|
||||
FormatShowIndent
|
||||
FormatShowDetails
|
||||
FormatShowCause
|
||||
FormatShowTrace
|
||||
FormatShowFieldEmpty
|
||||
)
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
FormatShow uint8
|
||||
|
||||
)
|
||||
|
||||
func (u FormatShow) ShowType () bool {
|
||||
return u&FormatShowType !=0 }
|
||||
|
||||
func (u FormatShow) ShowColors () bool {
|
||||
return u&FormatShowColors !=0 }
|
||||
|
||||
func (u FormatShow) ShowIndent () bool {
|
||||
return u&FormatShowIndent !=0 }
|
||||
|
||||
func (u FormatShow) ShowDetails() bool {
|
||||
return u&FormatShowDetails !=0 }
|
||||
|
||||
func (u FormatShow) ShowCause () bool {
|
||||
return u&FormatShowCause !=0 }
|
||||
|
||||
func (u FormatShow) ShowTrace () bool {
|
||||
return u&FormatShowTrace !=0 }
|
||||
|
||||
func (u FormatShow) ShowFieldEmpty () bool {
|
||||
return u&FormatShowFieldEmpty !=0 }
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name formattable.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
Formattable interface {
|
||||
|
||||
Build (builder FormatBuilder)
|
||||
|
||||
}
|
||||
|
||||
FormattableFnc func(builder FormatBuilder)
|
||||
|
||||
)
|
||||
|
||||
|
||||
func (f FormattableFnc) Build (builder FormatBuilder) {
|
||||
f(builder) }
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name err_cause.go
|
||||
// Created by DEV
|
||||
// Modified 23/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
type (
|
||||
|
||||
ErrCause struct {
|
||||
error
|
||||
cause error
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func NewErrCause (err error, cause error) *ErrCause {
|
||||
if err == nil || cause == nil {
|
||||
return nil
|
||||
}
|
||||
return &ErrCause{
|
||||
error: err,
|
||||
cause: cause,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (e ErrCause) Cause () error {
|
||||
return e.cause }
|
||||
|
||||
func (e ErrCause) Unwrap() error {
|
||||
return e.error }
|
||||
|
||||
|
||||
func (e ErrCause) StackTrace () StackTrace {
|
||||
if st,is := e.error.(StackTracer); is {
|
||||
return st.StackTrace()
|
||||
}
|
||||
if st,is := e.cause.(StackTracer); is { return st.StackTrace() }
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func (e ErrCause) ToErrInfo(options ...ErrInfoFnc) ErrInfo {
|
||||
return *NewErrInfo(e,options...) }
|
||||
|
||||
|
||||
func (e ErrCause) ToErrTrace(offset int) ErrTrace {
|
||||
return *NewErrTrace(e.error,offset) }
|
||||
|
||||
|
||||
func (e ErrCause) String () string {
|
||||
return string(G.Formatter.Format(e)) }
|
||||
@ -0,0 +1,64 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name err_code.go
|
||||
// Created by DEV
|
||||
// Modified 23/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
type (
|
||||
|
||||
ErrCode string
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
func (e ErrCode) Error () string {
|
||||
return string(e) }
|
||||
|
||||
func (e ErrCode) Code () string {
|
||||
return string(e) }
|
||||
|
||||
|
||||
|
||||
func (e ErrCode) Unwrap() error {
|
||||
return nil }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func (e ErrCode) ToErrCause(err error) ErrCause {
|
||||
return *NewErrCause(e,err) }
|
||||
|
||||
func (e ErrCode) ToErrInfo(options ...ErrInfoFnc) ErrInfo {
|
||||
return *NewErrInfo(e,options...) }
|
||||
|
||||
func (e ErrCode) ToErrTrace(offset int) ErrTrace {
|
||||
return *NewErrTrace(e,offset) }
|
||||
|
||||
|
||||
|
||||
func (e ErrCode) String () string {
|
||||
return string(G.Formatter.Format(e)) }
|
||||
@ -0,0 +1,76 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name err_multi.go
|
||||
// Created by DEV
|
||||
// Modified 29/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
ErrMulti ErrList
|
||||
|
||||
)
|
||||
|
||||
|
||||
func MakeErrMulti (err ...error) ErrMulti {
|
||||
return ErrMulti(ErrList(err).Clean()) }
|
||||
|
||||
|
||||
|
||||
|
||||
func (e ErrMulti) Error () string {
|
||||
return "multi-errors" }
|
||||
|
||||
|
||||
func (e ErrMulti) Map (mp func(error) bool) {
|
||||
for _,i := range e {
|
||||
if !mp(i) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (e ErrMulti) Unwrap() error {
|
||||
if len(e) > 0 {
|
||||
return nil
|
||||
}
|
||||
return e[0]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func (e ErrMulti) ToErrInfo(options ...ErrInfoFnc) ErrInfo {
|
||||
return *NewErrInfo(e,options ...) }
|
||||
|
||||
|
||||
func (e ErrMulti) ToErrTrace(offset int) ErrTrace {
|
||||
return *NewErrTrace(e,offset) }
|
||||
|
||||
|
||||
|
||||
func (e ErrMulti) String () string {
|
||||
return string(G.Formatter.Format(e)) }
|
||||
@ -0,0 +1,40 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name err_formatter.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
ErrorFormatter interface {
|
||||
|
||||
Format (err error) []byte
|
||||
}
|
||||
|
||||
FormatErrorFnc func (err error)
|
||||
|
||||
)
|
||||
|
||||
|
||||
func (f FormatErrorFnc) Format (err error) {
|
||||
f(err) }
|
||||
@ -0,0 +1,53 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name error_format_builder.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
import "time"
|
||||
|
||||
type (
|
||||
|
||||
FormatBuilder interface {
|
||||
Reset ()
|
||||
|
||||
Level () int
|
||||
Error () error
|
||||
Bytes () []byte
|
||||
|
||||
AddError (err error, options ...FormatOpsFnc)
|
||||
AddCause (err error, options ...FormatOpsFnc)
|
||||
|
||||
AddTrace (trace StackTrace, options ...FormatOpsFnc)
|
||||
|
||||
AddString (str string, options ...FormatOpsFnc)
|
||||
AddStringLn (str string, options ...FormatOpsFnc)
|
||||
|
||||
AddFieldString (name string, value string , options ...FormatOpsFnc)
|
||||
AddFieldInt (name string, value int , options ...FormatOpsFnc)
|
||||
AddFieldFloat (name string, value float64 , options ...FormatOpsFnc)
|
||||
AddFieldTime (name string, value time.Time, options ...FormatOpsFnc)
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name color.go
|
||||
// Created by DEV
|
||||
// Modified 27/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
|
||||
FormatColorBlack FormatColor = iota + 30
|
||||
FormatColorRed
|
||||
FormatColorGreen
|
||||
FormatColorYellow
|
||||
FormatColorBlue
|
||||
FormatColorMagenta
|
||||
FormatColorCyan
|
||||
FormatColorWhite
|
||||
)
|
||||
|
||||
|
||||
type (
|
||||
|
||||
FormatColor uint8
|
||||
)
|
||||
|
||||
|
||||
func (c FormatColor) BeginColorString() string {
|
||||
return fmt.Sprintf("\u001B[%dm",uint8(c))
|
||||
}
|
||||
|
||||
func (_ FormatColor) EndColorString () string {
|
||||
return "\x1b[0m" }
|
||||
|
||||
|
||||
func (c FormatColor) Sprintf(fm string, params ...any) string {
|
||||
return fmt.Sprintf("\x1b[%dm%s\x1b[0m", uint8(c),fmt.Sprintf(fm,params...)) }
|
||||
|
||||
|
||||
func (c FormatColor) IsValid() bool {
|
||||
return c >= FormatColorBlack && c <= FormatColorWhite }
|
||||
@ -0,0 +1,37 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name error_formattable_options.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
FormatOps struct {
|
||||
FieldNameColor FormatColor
|
||||
FieldValueColor FormatColor
|
||||
}
|
||||
|
||||
FormatOpsFnc func (ops *FormatOps)
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name error_formatable.go
|
||||
// Created by DEV
|
||||
// Modified 30/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
type (
|
||||
|
||||
Formattable interface {
|
||||
|
||||
Build (builder FormatBuilder)
|
||||
|
||||
}
|
||||
|
||||
FormattableFnc func(builder FormatBuilder)
|
||||
|
||||
)
|
||||
|
||||
|
||||
func (f FormattableFnc) Build (builder FormatBuilder) {
|
||||
f(builder) }
|
||||
@ -0,0 +1,41 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name formatter.go
|
||||
// Created by DEV
|
||||
// Modified 25/03/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package errs
|
||||
|
||||
type (
|
||||
|
||||
Formatter interface {
|
||||
|
||||
Format (err error) []byte
|
||||
}
|
||||
|
||||
FormatFnc func (err error) []byte
|
||||
|
||||
)
|
||||
|
||||
|
||||
func (f FormatFnc) Format (err error) []byte {
|
||||
return f(err) }
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
module errs
|
||||
|
||||
go 1.22
|
||||
Loading…
Reference in new issue