1 /***************************************************************************
2   qgscplerrorhandler.h - QgsCplErrorHandler
3 
4  ---------------------
5  begin                : Oct 29, 2003
6  copyright            : (C) 2003 by Gary E.Sherman
7  email                : sherman at mrcc.com
8  ***************************************************************************
9  *                                                                         *
10  *   This program is free software; you can redistribute it and/or modify  *
11  *   it under the terms of the GNU General Public License as published by  *
12  *   the Free Software Foundation; either version 2 of the License, or     *
13  *   (at your option) any later version.                                   *
14  *                                                                         *
15  ***************************************************************************/
16 #ifndef QGSCPLERRORHANDLER_H
17 #define QGSCPLERRORHANDLER_H
18 
19 #include "gdal.h"
20 #include "qgsmessagelog.h"
21 
22 class QgsCPLErrorHandler
23 {
showError(CPLErr errClass,int errNo,const char * msg)24     static void CPL_STDCALL showError( CPLErr errClass, int errNo, const char *msg )
25     {
26       if ( errNo != OGRERR_NONE )
27         QgsMessageLog::logMessage( QObject::tr( "OGR[%1] error %2: %3" ).arg( errClass ).arg( errNo ).arg( msg ), QObject::tr( "OGR" ) );
28     }
29 
30   public:
QgsCPLErrorHandler()31     QgsCPLErrorHandler()
32     {
33       CPLPushErrorHandler( showError );
34     }
35 
~QgsCPLErrorHandler()36     ~QgsCPLErrorHandler()
37     {
38       CPLPopErrorHandler();
39     }
40 
41     QgsCPLErrorHandler( const QgsCPLErrorHandler &other ) = delete;
42     QgsCPLErrorHandler &operator=( const QgsCPLErrorHandler &other ) = delete;
43 
44 };
45 
46 
47 #endif // QGSCPLERRORHANDLER_H
48