2015-07-24 14:16:31 +00:00
|
|
|
// Copyright 2015 The go-python Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package bind
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2019-02-22 10:33:05 +00:00
|
|
|
"errors"
|
2015-07-24 14:16:31 +00:00
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ErrorList is a list of errors
|
|
|
|
type ErrorList []error
|
|
|
|
|
2019-02-22 10:33:05 +00:00
|
|
|
func (list *ErrorList) Add(err error) {
|
|
|
|
if err == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
*list = append(*list, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (list *ErrorList) Error() error {
|
2015-07-24 14:16:31 +00:00
|
|
|
buf := new(bytes.Buffer)
|
2019-02-22 10:33:05 +00:00
|
|
|
for i, err := range *list {
|
2015-07-24 14:16:31 +00:00
|
|
|
if i > 0 {
|
|
|
|
buf.WriteRune('\n')
|
|
|
|
}
|
|
|
|
io.WriteString(buf, err.Error())
|
|
|
|
}
|
2019-02-22 10:33:05 +00:00
|
|
|
return errors.New(buf.String())
|
2015-07-24 14:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
doDebug = true
|
|
|
|
)
|
|
|
|
|
|
|
|
func debugf(format string, args ...interface{}) (int, error) {
|
|
|
|
if doDebug {
|
|
|
|
return fmt.Fprintf(os.Stderr, format, args...)
|
|
|
|
}
|
|
|
|
return 0, nil
|
|
|
|
}
|