diff --git a/web/pgadmin/static/jsx/history/detail/history_error_message.jsx b/web/pgadmin/static/jsx/history/detail/history_error_message.jsx index af77a90..352f229 100644 --- a/web/pgadmin/static/jsx/history/detail/history_error_message.jsx +++ b/web/pgadmin/static/jsx/history/detail/history_error_message.jsx @@ -14,6 +14,16 @@ import Shapes from '../../react_shapes'; export default class HistoryErrorMessage extends React.Component { parseErrorMessage(message) { + /* + * Below regex pattern will match `********** Error **********` string in message + * and if we found it then we will remove it to make the error clear. + */ + var psycopg_error_pattern = /[\*]{10}[\w|\s]+[\*]{10}/i; + if(psycopg_error_pattern.test(message)) { + message = message.replace(psycopg_error_pattern, ''); + } + + // Extract relevant error from message if pattern is found else return message return message.match(/ERROR:\s*([^\n\r]*)/i) ? message.match(/ERROR:\s*([^\n\r]*)/i)[1] : message; diff --git a/web/regression/javascript/history/query_history_spec.jsx b/web/regression/javascript/history/query_history_spec.jsx index 0a96244..118b9aa 100644 --- a/web/regression/javascript/history/query_history_spec.jsx +++ b/web/regression/javascript/history/query_history_spec.jsx @@ -383,6 +383,44 @@ describe('QueryHistory', () => { expect(queryDetail.at(0).text()).toContain('third sql statement'); }); }); + + describe('when a fourth SQL query is executed', () => { + beforeEach(() => { + historyCollection.add({ + query: 'fourth sql statement', + start_time: new Date(2017, 12, 12, 1, 33, 5, 99), + status: false, + row_affected: 0, + total_time: '26 msec', + message: 'unexpected error from fourth sql message', + }); + + queryEntries = historyWrapper.find(QueryHistoryEntry); + }); + + it('displays fourth query SQL in the right pane', () => { + expect(queryDetail.at(0).text()).toContain('unexpected error from fourth sql message'); + }); + }); + + describe('when a fifth SQL query is executed', () => { + beforeEach(() => { + historyCollection.add({ + query: 'fifth sql statement', + start_time: new Date(2017, 12, 12, 1, 34, 5, 99), + status: false, + row_affected: 0, + total_time: '26 msec', + message: 'testing unknown exception********** Error ********** using regex', + }); + + queryEntries = historyWrapper.find(QueryHistoryEntry); + }); + + it('displays fifth query SQL in the right pane', () => { + expect(queryDetail.at(0).text()).toContain('Error Message testing unknown exception using regex'); + }); + }); }); describe('when several days of queries were executed', () => {