You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool/nmap/errors.go

40 lines
584 B
Go

package nmap
import "strings"
// ErrMap multi error map
type ErrMap map[string]error
// Error string
func (e ErrMap) Error() string {
var sb strings.Builder
for name, err := range e {
sb.WriteString(name)
sb.WriteByte(':')
sb.WriteString(err.Error())
sb.WriteByte('\n')
}
return sb.String()
}
// ErrorOrNil error
func (e ErrMap) ErrorOrNil() error {
if len(e) == 0 {
return nil
}
return e
}
// IsEmpty error
func (e ErrMap) IsEmpty() bool {
return len(e) == 0
}
// One error
func (e ErrMap) One() error {
for _, err := range e {
return err
}
return nil
}