Hi Dave,

PFA patch.

On Mon, Sep 18, 2017 at 4:34 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Mon, Sep 18, 2017 at 10:54 AM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA minor patch to fix the issue where logic to extract the error using
>> RegEX from error message was incorrect in Query tool(History tab).
>> RM#2700
>>
>
> Thanks - applied, but....
>
> - Could you please add some JS tests to ensure parseErrorMessage continues
> to work as it should.
>
​Done​


>
> - I'm not happy with the fact that we still display:
>
> can't execute an empty query ********** Error **********
>
> Can we not make that look more like a real error message? At the very
> least something like:
>
> Error: can't execute an empty query
>
​Done​


>
>
>>
>> Another minor issue which I observed on login page is that close button
>> on alert is little misaligned(screenshot attached).
>>
>>
> Also applied - thanks!
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
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..63f5e14 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.
+     */
+    let 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', () => {

Reply via email to