<commit_before>package chkitErrors

import (
	"bytes"
	"fmt"
)

type Err string

func (err Err) Error() string {
	return string(err)
}

func (err Err) Errors() []error {
	return []error{err}
}

type Wrapper struct {
	main          error
	reasons       []error
	cachedMessage string
}

func (wrapper *Wrapper) AddReasons(reasons ...error) *Wrapper {
	for _, reason := range reasons {
		wrapper.reasons = append(wrapper.reasons, reason)
	}
	return wrapper
}

func (wrapper *Wrapper) AddReasonF(f string, vals ...interface{}) *Wrapper {
	return wrapper.AddReasons(fmt.Errorf(f, vals...))
}
func (wrapper *Wrapper) Error() string {
	if wrapper.cachedMessage != "" {
		return wrapper.cachedMessage
	}
	buf := bytes.NewBufferString(wrapper.main.Error())
	if len(wrapper.reasons) > 0 {
		buf.WriteString(": ")
	}
	for i, reason := range wrapper.reasons {
		if i != 0 {
			buf.WriteString(", " + reason.Error())
		} else {
			buf.WriteString(reason.Error())
		}
	}
	wrapper.cachedMessage = buf.String()
	return wrapper.cachedMessage
}

func (wrapper *Wrapper) Match(errs ...error) bool {
	for _, err := range errs {
		if wrapper.main == err {
			return true
		}
	}
	return false
}

func (wrapper *Wrapper) Errors() []error {
	errs := make([]error, len(wrapper.reasons))
	copy(errs, wrapper.reasons)
	return errs
}
<commit_msg>add cli interface impls<commit_after>package chkitErrors

import (
	"bytes"
	"fmt"

	"gopkg.in/urfave/cli.v2"
)

type Err string

var (
	_ error          = Err("")
	_ cli.ExitCoder  = Err("")
	_ cli.MultiError = Err("")

	_ error          = &Wrapper{}
	_ cli.ExitCoder  = &Wrapper{}
	_ cli.MultiError = &Wrapper{}
)

func (err Err) Error() string {
	return string(err)
}
func (err Err) Errors() []error {
	return []error{err}
}

func (err Err) ExitCode() int {
	return 1
}
func (err Err) Wrap(errs ...error) *Wrapper {
	return Wrap(err, errs...)
}

type Wrapper struct {
	main          error
	reasons       []error
	cachedMessage string
}

func Wrap(err error, reasons ...error) *Wrapper {
	return &Wrapper{
		main:    err,
		reasons: reasons,
	}
}

func (wrapper *Wrapper) AddReasons(reasons ...error) *Wrapper {
	for _, reason := range reasons {
		wrapper.reasons = append(wrapper.reasons, reason)
	}
	return wrapper
}

func (wrapper *Wrapper) AddReasonF(f string, vals ...interface{}) *Wrapper {
	return wrapper.AddReasons(fmt.Errorf(f, vals...))
}
func (wrapper *Wrapper) Error() string {
	if wrapper.cachedMessage != "" {
		return wrapper.cachedMessage
	}
	buf := bytes.NewBufferString(wrapper.main.Error())
	if len(wrapper.reasons) > 0 {
		buf.WriteString(": ")
	}
	for i, reason := range wrapper.reasons {
		if i != 0 {
			buf.WriteString(", " + reason.Error())
		} else {
			buf.WriteString(reason.Error())
		}
	}
	wrapper.cachedMessage = buf.String()
	return wrapper.cachedMessage
}

func (wrapper *Wrapper) Match(errs ...error) bool {
	for _, err := range errs {
		if wrapper.main == err {
			return true
		}
	}
	return false
}

func (wrapper *Wrapper) Errors() []error {
	errs := make([]error, len(wrapper.reasons))
	copy(errs, wrapper.reasons)
	return errs
}

func (wrapper *Wrapper) ExitCode() int {
	return 1
}

{'fraction_non_alphanumeric': 0.148902322621699, 'fraction_numerical': 0.0022271714922048997, 'mean_word_length': 3.5499276410998553, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2453474', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1106, 'n_words': 286}