Make CLI functions return error instead of fatal out (#1379)
Before this PR, CLI functions fatal out when encountering error instead of returning it. Such behavior makes it hard to reuse the functions nor writing unit tests. This PR aims to make functions return errors instead of error out.
This commit is contained in:
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/ghodss/yaml"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/log"
|
||||
"github.com/fission/fission/pkg/fission-cli/consolemsg"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ func getPodFileName(dumpdir string, pod metav1.ObjectMeta, containerName string)
|
||||
func writeToFile(file string, obj interface{}) {
|
||||
bs, err := yaml.Marshal(obj)
|
||||
if err != nil {
|
||||
log.Info(fmt.Sprintf("Error encoding object: %v", err))
|
||||
consolemsg.Info(fmt.Sprintf("Error encoding object: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@ func writeToFile(file string, obj interface{}) {
|
||||
|
||||
err = ioutil.WriteFile(file, bs, 0644)
|
||||
if err != nil {
|
||||
log.Info(fmt.Sprintf("Error writing file %v: %v", file, err))
|
||||
consolemsg.Info(fmt.Sprintf("Error writing file %v: %v", file, err))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user