Skip to content

Commit ec50876

Browse files
committed
parse validation error for sld (#3717)
1 parent ed530d1 commit ec50876

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

web/client/reducers/__tests__/styleeditor-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,20 @@ describe('Test styleeditor reducer', () => {
130130
}
131131
});
132132
});
133+
134+
it('test errorStyle sld error', () => {
135+
const state = styleeditor({ }, errorStyle('edit', { status: 400, statusText: 'Error on lineNumber: 10; columnNumber: 2;' }));
136+
expect(state).toEqual({
137+
loading: false,
138+
canEdit: true,
139+
error: {
140+
edit: {
141+
status: 400,
142+
message: 'Error on lineNumber: 10; columnNumber: 2;',
143+
line: 10,
144+
column: 2
145+
}
146+
}
147+
});
148+
});
133149
});

web/client/reducers/styleeditor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ function styleeditor(state = {}, action) {
8686
}
8787
case ERROR_STYLE: {
8888
const message = action.error && action.error.statusText || '';
89-
const position = message.match(/line\s([\d]+)|column\s([\d]+)/g);
89+
const position = message.match(/line\s([\d]+)|column\s([\d]+)|lineNumber:\s([\d]+)|columnNumber:\s([\d]+)/g);
9090
const errorInfo = position && position.length === 2 && position.reduce((info, pos) => {
9191
const splittedValues = pos.split(' ');
92-
const param = splittedValues[0];
92+
const param = splittedValues[0].replace(/Number:/g, '');
9393
const value = parseFloat(splittedValues[1]);
9494
return param && !isNaN(value) && {
9595
...info,

0 commit comments

Comments
 (0)