Skip to content

Commit 6318863

Browse files
committed
fix(eclwatch): display error message in WUResult table
catch exception thrown in wuResult.fetchRows() and pass that message back to the dgrid table to display instead of the normal noDataMessage HPCC-32576 (Viewing a file does not pass back errors to the user) Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com>
1 parent 22e4f57 commit 6318863

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

packages/dgrid/src/Common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export class Common extends HTMLWidget {
2323
noDataMessage: publish<this, string>;
2424
@publish("loading...", "string", "Loading Message")
2525
loadingMessage: publish<this, string>;
26+
@publish("An exception has occurred", "string", "Exception Message")
27+
exceptionMessage: publish<this, string>;
2628
@publish(false, "boolean", "Enable paging")
2729
pagination: publish<this, boolean>;
2830
@publish(25, "number", "Page size")
@@ -58,7 +60,7 @@ export class Common extends HTMLWidget {
5860
const retVal = [];
5961
for (const id in this._dgrid.selection) {
6062
if (this._dgrid.selection[id]) {
61-
const storeItem = this._store.get(+id);
63+
const storeItem = this._store.get(+id);
6264
retVal.push(this.rowToObj(storeItem));
6365
}
6466
}

packages/eclwatch/src/WUResult.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ export class WUResult extends Common {
9292
const result = this.calcResult();
9393
if (result) {
9494
result.fetchXMLSchema().then(schema => {
95-
this._localStore = new Store(result, schema, this.renderHtml(), this.filter());
95+
this._localStore = new Store(result, schema, this.renderHtml(), this.filter(), (msg) => {
96+
this.exceptionMessage(msg);
97+
if (this._dgrid) {
98+
this._dgrid.noDataMessage = `<span class='dojoxGridNoData'>${this.exceptionMessage()}</span>`;
99+
this._dgrid.refresh();
100+
}
101+
});
96102
this._dgrid?.set("columns", this._localStore.columns());
97103
this._dgrid?.set("collection", this._localStore);
98104
});

packages/eclwatch/src/WUResultStore.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResultFilter, Result, XSDSchema, XSDXMLNode } from "@hpcc-js/comms";
1+
import { Exception, ResultFilter, Result, XSDSchema, XSDXMLNode } from "@hpcc-js/comms";
22
import { ColumnType, Deferred, domConstruct, QueryResults, RowFormatter } from "@hpcc-js/dgrid";
33

44
function entitiesEncode(str) {
@@ -26,13 +26,16 @@ export class Store {
2626
protected _cache: { [key: string]: Promise<{ totalLength: number, data: any[] }> } = {};
2727
private rowFormatter: RowFormatter;
2828
protected _filter: ResultFilter = {};
29+
private onError?: (msg: string) => void;
30+
private _lastError: string | null = null;
2931

30-
constructor(wuResult: Result, schema: XSDSchema, renderHtml: boolean, filter: ResultFilter = {}) {
32+
constructor(wuResult: Result, schema: XSDSchema, renderHtml: boolean, filter: ResultFilter = {}, onError?: (msg: string) => void) {
3133
this.wuResult = wuResult;
3234
this.schema = schema;
3335
this._columns = this.schema2Columns(this.schema.root);
3436
this.rowFormatter = new RowFormatter(this._columns, renderHtml);
3537
this._filter = filter;
38+
this.onError = onError;
3639
}
3740

3841
columns() {
@@ -182,11 +185,25 @@ export class Store {
182185
return formattedRow;
183186
})
184187
};
188+
}).catch((err: Exception) => {
189+
this._lastError = err.Message || "An exception has occurred";
190+
if (this.onError) {
191+
this.onError(this._lastError);
192+
}
193+
return { totalLength: 0, data: [] };
185194
});
186195
this._cache[cacheKey] = retVal;
187196
return retVal;
188197
}
189198

199+
hasError() {
200+
return !!this._lastError;
201+
}
202+
203+
getLastError() {
204+
return this._lastError;
205+
}
206+
190207
fetchRange(options): Promise<any[]> {
191208
const retVal = new Deferred();
192209
this._request(options.start, options.end).then(response => retVal.resolve(response));

0 commit comments

Comments
 (0)