Skip to content

Commit

Permalink
fix(sdk): json to struct error message missing dash (#3924)
Browse files Browse the repository at this point in the history
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)*.
  • Loading branch information
hasanaburayyan authored Aug 23, 2023
1 parent 29adc4f commit f6a363a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libs/wingsdk/src/std/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Struct {
const result = validator.validate(obj, schema);
if (result.errors.length > 0) {
throw new Error(
`unable to parse ${schema.id.replace("/", "")}:\n ${result.errors.join(
`unable to parse ${schema.id.replace("/", "")}:\n- ${result.errors.join(
"\n- "
)}`
);
Expand Down
10 changes: 5 additions & 5 deletions tools/hangar/__snapshots__/error.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Duration <DURATION>"
exports[`struct_from_json_1.w 1`] = `
"ERROR: unable to parse Person:
instance.age is not of a type(s) number
- instance.age is not of a type(s) number
../../../examples/tests/error/target/test/struct_from_json_1.wsim.[REDACTED].tmp/.wing/preflight.js:9
const Person = require(\\"./Person.Struct.js\\")($stdlib.std.Struct, $stdlib.core.NodeJsCode.fromInline);
Expand All @@ -134,7 +134,7 @@ Duration <DURATION>"
exports[`struct_from_json_2.w 1`] = `
"ERROR: unable to parse Student:
instance.age is not of a type(s) number
- instance.age is not of a type(s) number
- instance requires property \\"advisor\\"
../../../examples/tests/error/target/test/struct_from_json_2.wsim.[REDACTED].tmp/.wing/preflight.js:11
Expand All @@ -153,7 +153,7 @@ Duration <DURATION>"
exports[`struct_from_json_3.w 1`] = `
"ERROR: unable to parse Student:
instance.age is not of a type(s) number
- instance.age is not of a type(s) number
- instance.advisors[1].id is not of a type(s) string
../../../examples/tests/error/target/test/struct_from_json_3.wsim.[REDACTED].tmp/.wing/preflight.js:11
Expand All @@ -172,7 +172,7 @@ Duration <DURATION>"
exports[`struct_from_json_4.w 1`] = `
"ERROR: unable to parse Student:
instance.advisors contains duplicate item
- instance.advisors contains duplicate item
../../../examples/tests/error/target/test/struct_from_json_4.wsim.[REDACTED].tmp/.wing/preflight.js:11
const Student = require(\\"./Student.Struct.js\\")($stdlib.std.Struct, $stdlib.core.NodeJsCode.fromInline);
Expand All @@ -190,7 +190,7 @@ Duration <DURATION>"
exports[`struct_from_json_5.w 1`] = `
"ERROR: unable to parse Foo:
instance.names.c is not of a type(s) string
- instance.names.c is not of a type(s) string
../../../examples/tests/error/target/test/struct_from_json_5.wsim.[REDACTED].tmp/.wing/preflight.js:9
const Foo = require(\\"./Foo.Struct.js\\")($stdlib.std.Struct, $stdlib.core.NodeJsCode.fromInline);
Expand Down

0 comments on commit f6a363a

Please sign in to comment.