|
Exceptions
class Exception
{
public:
int get_error_code();
string get_human_hres();
string const & get_error_message();
}
Sample
try
{
db mydb("jobs");
mydb.new_table();
mydb.set_field("name", db_string);
mydb.commit_table("employee");
mydb.get_field_string("employee", 0, "name");//throws an exception:
//the record 0 does not exist...
}
catch (Exception e)
{
//you can either test for a specific error number, or display the
//message generated by the exception...
printf(e.get_error_message().c_str());
printf(e.get_human_hres().c_str());
int error_code=e.get_error_code();
}
catch (...) //we catch other types of exceptions such as access fault...
{
//...
}
Exceptions thrown by Quickdb
Quickdb is a COM server, therefore cannot throw exceptions. However, each method of the call Quickdb returns an error code (in case of error). The class Exception is just used to take as input the error code returned by a method and throws an exception according to this error code...
List of exceptions thrown
Exception code |
Error message |
1 |
The name does not correspond to any index |
2 |
The index does not correspond to any name |
3 |
temporary table not created |
4 |
the table has not been chosen to create a new record |
5 |
the record does not contain so many fields |
6 |
this is not a relation field |
7 |
the reference has not been found |
8 |
this is not a long field |
9 |
this not an int field |
10 |
this is not a string field |
11 |
temporary record not created |
12 |
child table not found |
13 |
index out of range when retrieving the list of children |
14 |
index out of range |
XML |
errors thrown with XML operations |
101 |
error opening file for reading |
102 |
eror opening file for writing |
103 |
the file has not been parsed up to the end |
104 |
tag not closed |
105 |
the comment is not valid |
106 |
token not recognised |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|