Skip to content

Commit

Permalink
fix(moncaco/validate): handle metadata being undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Jan 25, 2024
1 parent bd60557 commit be3dfa3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/tools/monaco/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ export function validateDSL(monaco: typeof MonacoEditor, dsl: string): Marker[]
}

const extraInformation: Marker["extraInformation"] = {};
const errorMetadata = singleErr.metadata as any;
if (errorMetadata.errorType) {
extraInformation.error = errorMetadata.errorType;
}
["typeName", "relation"].forEach((field) => {
if (errorMetadata[field]) {
(extraInformation as any)[field] = errorMetadata[field];
const errorMetadata = singleErr.metadata;
if (errorMetadata) {
if ("errorType" in errorMetadata) {
extraInformation.error = errorMetadata.errorType;
}
});
["typeName", "relation"].forEach((field) => {
if (field in errorMetadata) {
(extraInformation as any)[field] = (errorMetadata as any)[field];
}
});
}

markers.push({
message: singleErr.msg,
Expand Down

0 comments on commit be3dfa3

Please sign in to comment.