The VError class is the class thrown by the VIPS C++ API when an error is detected. It is derived from std::exception in the usual way.
There are two constructors for VError:
VError( std::string str );
VError(); |
The first form creates an error object initialised with the specified string, the last form creates an empty error object.
A function gives access to the string held by VError:
const char ⋆what();
|
You can also send to an ostream.
std::ostream& operator<<(
std::ostream&, const error& ); |
Two member functions let you append elements to an error:
VError &app( std::string txt );
VError &app( const int i ); |
For example:
VError wombat;
int n = 12; wombat.app( "possum: no more than " ). app( n ).app( " elements\n" ); throw( wombat ); |
will throw a VError with a diagnostic of:
possum: no more than 12 elements
|
The member function perror() prints the error message to stdout and exits with a code of 1.
void perror( const char ⋆ );
void perror(); |
The convenience function verror creates an VError with the specified error string, and throws it. If you pass "" for the string, verror uses the contents of the VIPS error buffer instead.
extern void verror( std::string str = "" );
|