Skip to content

Commit

Permalink
Added skeleton data error reporting in editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Feb 22, 2023
1 parent 261e7db commit 3905f81
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions frontend/src/js/ui/components/template-edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default () => {
testConfig: {},
onRender: null,
templateErrors: [],
skeletonErrors: [],
listTemplateErrors: [],
entries: [],
entriesSearch: '',
Expand Down Expand Up @@ -213,13 +214,40 @@ export default () => {
}
return data;
}}
errorProvider={() => state.skeletonErrors}
onchange={(data) => {
state.skeletonDataRaw = data;
try {
state.target.skeletonData = JSON.parse(data);
updateRender();
state.skeletonErrors = [];
} catch (e) {
console.log(e);

let match = /at position (\d+)/.exec(e.toString());
if (!match) {
state.skeletonErrors = [
{
error: e.toString(),
line: data.split('\n').length,
column: 2,
},
];
return;
}

let errPos = parseInt(match[1]);
let lines = data.substring(0, errPos).split('\n');
let line = lines.length;
let column = 2;

state.skeletonErrors = [
{
error: e.toString(),
line: line,
column: column,
},
];
}
}}
/>
Expand Down

0 comments on commit 3905f81

Please sign in to comment.