summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-10-19 16:51:48 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-10-19 17:05:59 +0200
commit7260aa0cd70195a4679ca3c94204d9e618f947f2 (patch)
tree9321f5f3d21b06d1ab6dd50420879bc5ea41f044 /internal/config
parentf1a265190d8fd862bfff680fd0937a7f99759955 (diff)
Refactor: Make errors use the parent's error level
- All wrapped errors have to be created with types.NewWrappedError to inherit the error level from the parent - Or types.NewWrappedErrorLevel can be used which means a custom error level is given. For example this is done with cancelling OAuth - Client public errors are forwarded with handleError that also logs it with the error's level
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 1d5a201..180b881 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -29,11 +29,11 @@ func (config *Config) Save(readStruct interface{}) error {
errorMessage := "failed saving configuration"
configDirErr := util.EnsureDirectory(config.Directory)
if configDirErr != nil {
- return &types.WrappedErrorMessage{Message: errorMessage, Err: configDirErr}
+ return types.NewWrappedError(errorMessage, configDirErr)
}
jsonString, marshalErr := json.Marshal(readStruct)
if marshalErr != nil {
- return &types.WrappedErrorMessage{Message: errorMessage, Err: marshalErr}
+ return types.NewWrappedError(errorMessage, marshalErr)
}
return ioutil.WriteFile(config.GetFilename(), jsonString, 0o600)
}
@@ -41,7 +41,7 @@ func (config *Config) Save(readStruct interface{}) error {
func (config *Config) Load(writeStruct interface{}) error {
bytes, readErr := ioutil.ReadFile(config.GetFilename())
if readErr != nil {
- return &types.WrappedErrorMessage{Message: "failed loading configuration", Err: readErr}
+ return types.NewWrappedError("failed loading configuration", readErr)
}
return json.Unmarshal(bytes, writeStruct)
}