Skip to content

Commit d37d006

Browse files
committed
Minor: better error handling
1 parent bf70931 commit d37d006

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

internal/asl/state_machine.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ func parseStates(statesData string) (map[string]State, error) {
112112
}
113113

114114
parseable := emptyParsableFromType(StateType(stateType))
115+
if parseable == nil {
116+
return fmt.Errorf("invalid state type %s", stateType)
117+
}
115118
parsedState, err := parseable.ParseFrom(value)
116119
if err != nil {
117120
return fmt.Errorf("failed to parse state %s ...\n%v", value[:40], err)

internal/cli/cli.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ func invoke(cmd *cobra.Command, args []string) {
211211
}
212212
if len(paramsFile) > 0 {
213213
jsonFile, err := os.Open(paramsFile)
214+
if err != nil {
215+
fmt.Printf("Could not open parameters file '%s'\n", paramsFile)
216+
os.Exit(1)
217+
}
214218

215219
defer func(jsonFile *os.File) {
216220
err := jsonFile.Close()
@@ -516,6 +520,10 @@ func invokeWorkflow(cmd *cobra.Command, args []string) {
516520
}
517521
if len(paramsFile) > 0 {
518522
jsonFile, err := os.Open(paramsFile)
523+
if err != nil {
524+
fmt.Printf("Could not open parameters file '%s'\n", paramsFile)
525+
os.Exit(1)
526+
}
519527
defer jsonFile.Close()
520528
byteValue, _ := io.ReadAll(jsonFile)
521529
err = json.Unmarshal(byteValue, &paramsMap)

0 commit comments

Comments
 (0)