diff options
| author | Mistivia <i@mistivia.com> | 2025-11-02 15:27:18 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-11-02 15:27:18 +0800 |
| commit | e9c24f4af7ed56760f6db7941827d09f6db9020b (patch) | |
| tree | 62128c43b883ce5e3148113350978755779bb5de /teleirc/matterbridge/vendor/go.mau.fi/libsignal/util/errorhelper | |
| parent | 58d5e7cfda4781d8a57ec52aefd02983835c301a (diff) | |
add matterbridge
Diffstat (limited to 'teleirc/matterbridge/vendor/go.mau.fi/libsignal/util/errorhelper')
| -rw-r--r-- | teleirc/matterbridge/vendor/go.mau.fi/libsignal/util/errorhelper/ErrorHelper.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/teleirc/matterbridge/vendor/go.mau.fi/libsignal/util/errorhelper/ErrorHelper.go b/teleirc/matterbridge/vendor/go.mau.fi/libsignal/util/errorhelper/ErrorHelper.go new file mode 100644 index 0000000..b30adb0 --- /dev/null +++ b/teleirc/matterbridge/vendor/go.mau.fi/libsignal/util/errorhelper/ErrorHelper.go @@ -0,0 +1,40 @@ +package errorhelper + +// NewMultiError returns a new MultiError object. +func NewMultiError() *MultiError { + return &MultiError{ + errors: []error{}, + } +} + +// MultiError is a structure for holding multiple errors so they +// can be checked at a later point. +type MultiError struct { + errors []error +} + +// Add will add the given error if it is not nil. +func (m *MultiError) Add(err error) { + if err != nil { + m.errors = append(m.errors, err) + } +} + +// HasErrors will return true if any non-nil errors have been +// added. +func (m *MultiError) HasErrors() bool { + if len(m.errors) > 0 { + return true + } + + return false +} + +// Error will print the first error is encountered. +func (m *MultiError) Error() string { + if !m.HasErrors() { + return "" + } + + return m.errors[0].Error() +} |
