Skip to content

Commit d9bf9bc

Browse files
pauleflclaude
andcommitted
fix(add): handle json.MarshalIndent errors in add view/specification output
Replace silent error discard with proper error propagation in the JSON output path of runAddView and the two runAddSpecification* functions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a752474 commit d9bf9bc

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

cmd/bausteinsicht/add_specification.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ func runAddSpecificationElement(cmd *cobra.Command, args []string) error {
102102
if description != "" {
103103
result["description"] = description
104104
}
105-
jsonBytes, _ := json.MarshalIndent(result, "", " ")
105+
jsonBytes, err := json.MarshalIndent(result, "", " ")
106+
if err != nil {
107+
return fmt.Errorf("encoding result: %w", err)
108+
}
106109
fmt.Println(string(jsonBytes))
107110
} else {
108111
fmt.Printf("Element type '%s' added to specification\n", key)
@@ -190,7 +193,10 @@ func runAddSpecificationRelationship(cmd *cobra.Command, args []string) error {
190193
if description != "" {
191194
result["description"] = description
192195
}
193-
jsonBytes, _ := json.MarshalIndent(result, "", " ")
196+
jsonBytes, err := json.MarshalIndent(result, "", " ")
197+
if err != nil {
198+
return fmt.Errorf("encoding result: %w", err)
199+
}
194200
fmt.Println(string(jsonBytes))
195201
} else {
196202
fmt.Printf("Relationship type '%s' added to specification\n", key)

cmd/bausteinsicht/add_view.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ func runAddView(cmd *cobra.Command, args []string) error {
101101
"scope": scope,
102102
"include": includes,
103103
}
104-
jsonBytes, _ := json.MarshalIndent(result, "", " ")
104+
jsonBytes, err := json.MarshalIndent(result, "", " ")
105+
if err != nil {
106+
return fmt.Errorf("encoding result: %w", err)
107+
}
105108
fmt.Println(string(jsonBytes))
106109
} else {
107110
fmt.Printf("View '%s' added to model\n", viewKey)

0 commit comments

Comments
 (0)