• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

soprano

Error handling in Soprano

Soprano tries to simulate exceptions through the usage of Soprano::Error::ErrorCache.

Most methods in Soprano classes have a means of reporting if an operation was successful or not. For additional error information they inherit Soprano::Error::ErrorCache which provides the method Soprano::Error::ErrorCache::lastError().

Thus, advanced error handling would look as follows:

 Soprano::Model* model = Soprano::createModel();
 Soprano::Statement invalidStatement;
 if( model->addStatement( invalidStatement ) != Error::ErrorNone ) {
    showErrorMessage( model->lastError().message() );
 }

For methods that do not return an immediate error status Soprano::Error::Error evalutes to a boolean. Thus, one can easily check if an error occured as follows:

 Soprano::StatementIterator it = model->listStatements();
 while( it.next() ) {
    doSomething( *it );
 }
 if( it.lastError() ) {
    displayError( "Iteration failed: " + it.lastError().message() );
 }

This has the same effect as checking for Soprano::Error::ErrorNone.

This error handling is thread-safe. Thus, two threads can for example call methods of one Model at the same time and still get proper Soprano::Error::Error instances back.

soprano

Skip menu "soprano"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal