system: wrap op errors
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 1m51s
Test / Hakurei (push) Successful in 3m18s
Test / Hpkg (push) Successful in 3m41s
Test / Sandbox (race detector) (push) Successful in 4m7s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Flake checks (push) Successful in 1m35s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 1m51s
Test / Hakurei (push) Successful in 3m18s
Test / Hpkg (push) Successful in 3m41s
Test / Sandbox (race detector) (push) Successful in 4m7s
Test / Hakurei (race detector) (push) Successful in 5m18s
Test / Flake checks (push) Successful in 1m35s
This passes more information allowing for better error handling. This eliminates generic WrapErr from system. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -41,15 +41,15 @@ func (m *Mkdir) apply(*I) error {
|
||||
msg.Verbose("ensuring directory", m)
|
||||
|
||||
// create directory
|
||||
err := os.Mkdir(m.path, m.perm)
|
||||
if !errors.Is(err, os.ErrExist) {
|
||||
return wrapErrSuffix(err,
|
||||
fmt.Sprintf("cannot create directory %q:", m.path))
|
||||
if err := os.Mkdir(m.path, m.perm); err != nil {
|
||||
if !errors.Is(err, os.ErrExist) {
|
||||
return newOpError("mkdir", err, false)
|
||||
}
|
||||
// directory exists, ensure mode
|
||||
return newOpError("mkdir", os.Chmod(m.path, m.perm), false)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// directory exists, ensure mode
|
||||
return wrapErrSuffix(os.Chmod(m.path, m.perm),
|
||||
fmt.Sprintf("cannot change mode of %q to %s:", m.path, m.perm))
|
||||
}
|
||||
|
||||
func (m *Mkdir) revert(_ *I, ec *Criteria) error {
|
||||
@@ -60,8 +60,7 @@ func (m *Mkdir) revert(_ *I, ec *Criteria) error {
|
||||
|
||||
if ec.hasType(m) {
|
||||
msg.Verbose("destroying ephemeral directory", m)
|
||||
return wrapErrSuffix(os.Remove(m.path),
|
||||
fmt.Sprintf("cannot remove ephemeral directory %q:", m.path))
|
||||
return newOpError("mkdir", os.Remove(m.path), true)
|
||||
} else {
|
||||
msg.Verbose("skipping ephemeral directory", m)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user