error-firebird.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, Rafal Bobrowski
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #define SOCI_FIREBIRD_SOURCE
9 #include "soci-firebird.h"
10 #include "error-firebird.h"
11 
12 #include <cstdlib>
13 #include <string>
14 
15 namespace soci
16 {
17 
18 firebird_soci_error::firebird_soci_error(std::string const & msg, ISC_STATUS const * status)
19  : soci_error(msg)
20 {
21  if (status != 0)
22  {
23  std::size_t i = 0;
24  while (i < stat_size && status[i] != 0)
25  {
26  status_.push_back(status[i++]);
27  }
28  }
29 }
30 
31 namespace details
32 {
33 
34 namespace firebird
35 {
36 
37 void get_iscerror_details(ISC_STATUS * status_vector, std::string &msg)
38 {
39  char msg_buffer[SOCI_FIREBIRD_ERRMSG];
40  const ISC_STATUS *pvector = status_vector;
41 
42  try
43  {
44  // fetching first error message
45  fb_interpret(msg_buffer, SOCI_FIREBIRD_ERRMSG, &pvector);
46  msg = msg_buffer;
47 
48  // fetching next errors
49  while (fb_interpret(msg_buffer, SOCI_FIREBIRD_ERRMSG, &pvector))
50  {
51  msg += "\n";
52  msg += msg_buffer;
53  }
54  }
55  catch (...)
56  {
57  throw firebird_soci_error("Exception catched while fetching error information");
58  }
59 }
60 
61 bool check_iscerror(ISC_STATUS const * status_vector, long errNum)
62 {
63  std::size_t i=0;
64  while (status_vector[i] != 0)
65  {
66  if (status_vector[i] == 1 && status_vector[i+1] == errNum)
67  {
68  return true;
69  }
70  ++i;
71  }
72 
73  return false;
74 }
75 void throw_iscerror(ISC_STATUS * status_vector)
76 {
77  std::string msg;
78 
79  get_iscerror_details(status_vector, msg);
80  throw firebird_soci_error(msg, status_vector);
81 }
82 
83 } // namespace firebird
84 
85 } // namespace details
86 
87 } // namespace soci
bool check_iscerror(ISC_STATUS const *status_vector, long errNum)
std::vector< ISC_STATUS > status_
Definition: soci-firebird.h:52
std::size_t const stat_size
Definition: soci-firebird.h:40
SOCI_FIREBIRD_DECL firebird_backend_factory const firebird
void throw_iscerror(ISC_STATUS *status_vector)
std::size_t const SOCI_FIREBIRD_ERRMSG
Definition: soci-firebird.h:44
void get_iscerror_details(ISC_STATUS *status_vector, std::string &msg)
firebird_soci_error(std::string const &msg, ISC_STATUS const *status=0)


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40