mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-26 07:12:16 +00:00
* Enforce file permissions in case they've changed * test behaviour for autofile * use testify in tests and rename `fInf` to `fileInfo` * return an error if file permissions have changed - if we can't read the file, we'll still panic * get rid of "github.com/pkg/errors" dependency * address review comments: - prefix instead of suffix - add state to err and construct formatting in Error() method * address review comments: - move error to libs/errors
27 lines
602 B
Go
27 lines
602 B
Go
// Package errors contains errors that are thrown across packages.
|
|
package errors
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// ErrPermissionsChanged occurs if the file permission have changed since the file was created.
|
|
type ErrPermissionsChanged struct {
|
|
name string
|
|
got, want os.FileMode
|
|
}
|
|
|
|
func NewErrPermissionsChanged(name string, got, want os.FileMode) *ErrPermissionsChanged {
|
|
return &ErrPermissionsChanged{name: name, got: got, want: want}
|
|
}
|
|
|
|
func (e ErrPermissionsChanged) Error() string {
|
|
return fmt.Sprintf(
|
|
"file: [%v]\nexpected file permissions: %v, got: %v",
|
|
e.name,
|
|
e.want,
|
|
e.got,
|
|
)
|
|
}
|