diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-07-31 23:34:43 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-07-31 23:34:43 +0200 |
| commit | a2f8d7a68f324d5b4086148571f990409425e22a (patch) | |
| tree | f2756c205ad8bd897b48460c12191df8e2aa2cd6 /errors.go | |
| parent | 4e00aa81308e3f71c0c665ada873127dd1530480 (diff) | |
| download | go-oblast-a2f8d7a68f324d5b4086148571f990409425e22a.tar.gz | |
replace ioError with gg/errext.WithCleanup
Diffstat (limited to 'errors.go')
| -rw-r--r-- | errors.go | 37 |
1 files changed, 0 insertions, 37 deletions
@@ -26,40 +26,3 @@ func (e MissingRecordError[R]) Error() string { } return "could not UPDATE record that does not exist in the database: " + strings.Join(keyDescs, ", ") } - -// ioError is an error type that contains: -// - (optionally) a main error from an IO operation (e.g. a database read) -// - an auxiliary error from closing or otherwise cleaning up the respective IO handle -// -// This is only used when there is a cleanup error. -// Otherwise, the main error will be returned without being wrapped in this type. -type ioError struct { - MainError error - CleanupError error - CleanupOperation string -} - -func newIOError(err error, cleanupOperation string, cleanupErr error) error { - if cleanupErr == nil { - return err - } - return ioError{err, cleanupErr, cleanupOperation} -} - -// Error implements the builtin/error interface. -func (e ioError) Error() string { - if e.MainError == nil { - return fmt.Sprintf("during %s(): %s", e.CleanupOperation, e.CleanupError.Error()) - } else { - return fmt.Sprintf("%s (additional error during %s(): %s)", e.MainError.Error(), e.CleanupOperation, e.CleanupError.Error()) - } -} - -// Unwrap implements the interface implied by the documentation of package errors. -func (e ioError) Unwrap() []error { - if e.MainError == nil { - return []error{e.CleanupError} - } else { - return []error{e.MainError, e.CleanupError} - } -} |
