[prev] [prev-tail] [tail] [up]

### 1.6 The VError class

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.

#### 1.6.1 Constructors

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.

#### 1.6.2 Projection functions

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& );

#### 1.6.3 Computing with VError

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();

#### 1.6.4 Convenience function

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 = "" );

[prev] [prev-tail] [front] [up]