Skip to content

Commit f6a363a

Browse files
fix(sdk): json to struct error message missing dash (#3924)
Formatting was off for first error messages when failing to convert Json to Struct This is what it looked like <img width="620" alt="image" src="https://github.com/winglang/wing/assets/45375125/398f355e-7b95-4bef-8639-2ecac755be09"> Notice the first error was missing the `-` now it looks better <img width="601" alt="image" src="https://github.com/winglang/wing/assets/45375125/04425042-bb5c-40ad-bf06-e4a211ee7697"> ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
1 parent 29adc4f commit f6a363a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

libs/wingsdk/src/std/struct.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Struct {
5151
const result = validator.validate(obj, schema);
5252
if (result.errors.length > 0) {
5353
throw new Error(
54-
`unable to parse ${schema.id.replace("/", "")}:\n ${result.errors.join(
54+
`unable to parse ${schema.id.replace("/", "")}:\n- ${result.errors.join(
5555
"\n- "
5656
)}`
5757
);

tools/hangar/__snapshots__/error.ts.snap

+5-5
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Duration <DURATION>"
116116
117117
exports[`struct_from_json_1.w 1`] = `
118118
"ERROR: unable to parse Person:
119-
instance.age is not of a type(s) number
119+
- instance.age is not of a type(s) number
120120
121121
../../../examples/tests/error/target/test/struct_from_json_1.wsim.[REDACTED].tmp/.wing/preflight.js:9
122122
const Person = require(\\"./Person.Struct.js\\")($stdlib.std.Struct, $stdlib.core.NodeJsCode.fromInline);
@@ -134,7 +134,7 @@ Duration <DURATION>"
134134
135135
exports[`struct_from_json_2.w 1`] = `
136136
"ERROR: unable to parse Student:
137-
instance.age is not of a type(s) number
137+
- instance.age is not of a type(s) number
138138
- instance requires property \\"advisor\\"
139139
140140
../../../examples/tests/error/target/test/struct_from_json_2.wsim.[REDACTED].tmp/.wing/preflight.js:11
@@ -153,7 +153,7 @@ Duration <DURATION>"
153153
154154
exports[`struct_from_json_3.w 1`] = `
155155
"ERROR: unable to parse Student:
156-
instance.age is not of a type(s) number
156+
- instance.age is not of a type(s) number
157157
- instance.advisors[1].id is not of a type(s) string
158158
159159
../../../examples/tests/error/target/test/struct_from_json_3.wsim.[REDACTED].tmp/.wing/preflight.js:11
@@ -172,7 +172,7 @@ Duration <DURATION>"
172172
173173
exports[`struct_from_json_4.w 1`] = `
174174
"ERROR: unable to parse Student:
175-
instance.advisors contains duplicate item
175+
- instance.advisors contains duplicate item
176176
177177
../../../examples/tests/error/target/test/struct_from_json_4.wsim.[REDACTED].tmp/.wing/preflight.js:11
178178
const Student = require(\\"./Student.Struct.js\\")($stdlib.std.Struct, $stdlib.core.NodeJsCode.fromInline);
@@ -190,7 +190,7 @@ Duration <DURATION>"
190190
191191
exports[`struct_from_json_5.w 1`] = `
192192
"ERROR: unable to parse Foo:
193-
instance.names.c is not of a type(s) string
193+
- instance.names.c is not of a type(s) string
194194
195195
../../../examples/tests/error/target/test/struct_from_json_5.wsim.[REDACTED].tmp/.wing/preflight.js:9
196196
const Foo = require(\\"./Foo.Struct.js\\")($stdlib.std.Struct, $stdlib.core.NodeJsCode.fromInline);

0 commit comments

Comments
 (0)