comparison main/database/src/command.h @ 12718:1af86934c14e octave-forge

Make compatible with Octaves new exception-based error handling. Retain compatibility with Octaves old error handling based on error_state. * src/error_helpers.[h,cc]: Added. * src/Makefile.in: Integrate error-helpers.[h,cc]. * src/config.h.in: Added. * configure.ac, src/config.h.in: Test presence of 'error_state' and presence of 'verror (octave_execution_exception&, const char *, va_list)'. * src/__pq_connect__.cc, src/command.cc, src/command.h, src/converters.cc, src/converters_arr_comp.cc, src/pq_connection.cc, src/pq_conninfo.cc, src/pq_exec.cc, src/pq_lo.cc, src/pq_update_types.cc: If necessary, include error-helpers.h, replace error() with c_verror(), set and check a different error indicator than error_state, use CHECK_ERROR or SET_ERR, explicitely check for errors instead of relying on Octave checking error_state when returning to the prompt.
author i7tiol
date Sat, 27 Feb 2016 11:11:04 +0000
parents 2257648e8ce1
children 52ca082757c2
comparison
equal deleted inserted replaced
12717:87989220360f 12718:1af86934c14e
24 #include <octave/oct.h> 24 #include <octave/oct.h>
25 #include <octave/ov-struct.h> 25 #include <octave/ov-struct.h>
26 #include <octave/Cell.h> 26 #include <octave/Cell.h>
27 27
28 #include "pq_connection.h" 28 #include "pq_connection.h"
29 #include "error-helpers.h"
29 30
30 class 31 class
31 command 32 command
32 { 33 {
33 public: 34 public:
85 void check_first_result (void) 86 void check_first_result (void)
86 { 87 {
87 if (! res) 88 if (! res)
88 { 89 {
89 valid = 0; 90 valid = 0;
90 error ("%s: could not execute command: %s", caller.c_str (), 91 c_verror ("%s: could not execute command: %s", caller.c_str (),
91 PQerrorMessage (cptr)); 92 PQerrorMessage (cptr));
92 93
93 } 94 }
94 else if ((state = PQresultStatus (res)) == PGRES_EMPTY_QUERY) 95 else if ((state = PQresultStatus (res)) == PGRES_EMPTY_QUERY)
95 { 96 {
96 valid = 0; 97 valid = 0;
97 error ("%s: empty command", caller.c_str ()); 98 c_verror ("%s: empty command", caller.c_str ());
98 } 99 }
99 } 100 }
100 101
101 octave_value command_ok_handler (void) 102 octave_value command_ok_handler (void)
102 { 103 {