Skip to content

Commit b617161

Browse files
committed
DM-11013 Response to review comments
- fixed error message from backgrounded search - added check for failed status before tracking fetch - now returning DAX message rather then DAX error type - added error message to 'Unexpected error'
1 parent d53cf5e commit b617161

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/query/IpacTablePartProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ public DataGroupPart getData(ServerRequest sr) throws DataAccessException {
223223
throw dae;
224224
} catch (Exception e) {
225225
LOGGER.error(e, "Error while processing request:" + StringUtils.truncate(sr, 512));
226-
throw new DataAccessException("Unexpected error", e);
226+
String message = e.getMessage();
227+
if (message == null || message.length() < 5) message = "Unexpected error";
228+
throw new DataAccessException(message, e);
227229
}
228230
}
229231

src/firefly/java/edu/caltech/ipac/firefly/server/query/lsst/LSSTMetaSearch.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ static String getErrorMessageFromFile(File file) throws IOException, ParseExcep
5454
JSONParser parser = new JSONParser();
5555

5656
JSONObject obj = ( JSONObject) parser.parse(new FileReader(file ));
57-
return obj.get("error").toString();
57+
String message = obj.get("message").toString();
58+
String error = obj.get("error").toString();
59+
if (error != null && message != null) {
60+
return message.contains(error) ? message : error + " " + message;
61+
} else {
62+
return error;
63+
}
5864
}
5965

6066
private DataGroup getDataFromURL(TableServerRequest request) throws Exception {

src/firefly/js/core/background/BackgroundUtil.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
import {get} from 'lodash';
5+
import {get, omit} from 'lodash';
66
import Enum from 'enum';
77

88
import {flux} from '../../Firefly.js';
@@ -68,7 +68,7 @@ export function isActive(state) {
6868
}
6969

7070
export function getErrMsg(bgStatus) {
71-
return Object.entries(bgStatus).filter( ([k,v]) => k.startsWith('MESSAGE_'))
71+
return Object.entries(omit(bgStatus, 'MESSAGE_CNT')).filter( ([k,v]) => k.startsWith('MESSAGE_'))
7272
.map(([k,v]) => v)
7373
.join('; ');
7474
}

src/firefly/js/tables/TablesCntlr.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ function highlightRow(action) {
406406
TblUtil.doFetchTable(request, startIdx+hlRowIdx).then ( (tableModel) => {
407407
dispatch( {type:TABLE_HIGHLIGHT, payload: tableModel} );
408408
}).catch( (error) => {
409-
dispatch({type: TABLE_HIGHLIGHT, payload: TblUtil.createErrorTbl(tbl_id, `Fail to load table. \n ${error}`)});
409+
dispatch({type: TABLE_HIGHLIGHT, payload: TblUtil.createErrorTbl(tbl_id, `Failed to load table. \n ${error}`)});
410410
});
411411
}
412412
};
@@ -535,7 +535,7 @@ function syncFetch(request, hlRowIdx, invokedBy, dispatch) {
535535
const type = tableModel.origTableModel ? TABLE_REPLACE : TABLE_UPDATE;
536536
dispatch( {type, payload: tableModel} );
537537
}).catch( (error) => {
538-
dispatch({type: TABLE_UPDATE, payload: TblUtil.createErrorTbl(request.tbl_id, `Fail to load table. \n ${error}`)});
538+
dispatch({type: TABLE_UPDATE, payload: TblUtil.createErrorTbl(request.tbl_id, `Failed to load table. \n ${error}`)});
539539
});
540540
}
541541

@@ -546,12 +546,19 @@ function asyncFetch(request, hlRowIdx, invokedBy, dispatch) {
546546
const {ID, STATE} = bgStatus || {};
547547
if (isSuccess(STATE)) {
548548
syncFetch(request, hlRowIdx, invokedBy, dispatch);
549+
} else if (isFail(STATE)) {
550+
const error = getErrMsg(bgStatus);
551+
const {tbl_id} = request;
552+
dispatch({
553+
type: TABLE_UPDATE,
554+
payload: TblUtil.createErrorTbl(tbl_id, `Failed to load table. \n ${error}`)
555+
});
549556
} else {
550557
dispatchAddSaga( trackFetch, {request, hlRowIdx, invokedBy, bgID:ID, dispatch});
551558
dispatch({type: TABLE_UPDATE, payload: {tbl_id, bgStatus}});
552559
}
553560
}).catch( (error) => {
554-
dispatch({type: TABLE_UPDATE, payload: TblUtil.createErrorTbl(tbl_id, `Fail to load table. \n ${error}`)});
561+
dispatch({type: TABLE_UPDATE, payload: TblUtil.createErrorTbl(tbl_id, `Failed to load table. \n ${error}`)});
555562
});
556563
}
557564

@@ -567,7 +574,7 @@ function* trackFetch({request, hlRowIdx, invokedBy, bgID, dispatch}) {
567574
} else if (isFail(STATE)) {
568575
const error = getErrMsg(action.payload);
569576
const {tbl_id} = request;
570-
dispatch({ type: TABLE_UPDATE, payload: TblUtil.createErrorTbl(tbl_id, `Fail to load table. \n ${error}`)});
577+
dispatch({ type: TABLE_UPDATE, payload: TblUtil.createErrorTbl(tbl_id, `Failed to load table. \n ${error}`)});
571578
break;
572579
} else if (action.type === BG_JOB_ADD && ID === bgID) {
573580
// sent to background... no need to track this anymore.

src/firefly/js/tables/ui/TablePanel.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ export class TablePanel extends PureComponent {
116116
filterInfo, filterCount, sortInfo, data, bgStatus} = this.state;
117117
var {leftButtons, rightButtons} = this.state;
118118

119-
if (get(bgStatus, 'STATE') === 'FAIL') return <div className='TablePanel__error'>{get(bgStatus, 'MESSAGE_0', '')}</div>
120119
if (error) return <div className='TablePanel__error'>{error}</div>;
121120
if (isEmpty(columns)) return <Loading {...{showTitle, tbl_id, title, removable, bgStatus}}/>;
122121

0 commit comments

Comments
 (0)