mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-10-31 00:06:02 -04:00 
			
		
		
		
	Make sure Python exceptions are converted into QgsServerException and catched by the main service executor. Without this patch, the server process is terminated (aborted).
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| %Module(name=qgis._server,
 | |
|         keyword_arguments="All")
 | |
| 
 | |
| ${DEFAULTDOCSTRINGSIGNATURE}
 | |
| 
 | |
| %Import QtCore/QtCoremod.sip
 | |
| %Import QtGui/QtGuimod.sip
 | |
| %Import QtXml/QtXmlmod.sip
 | |
| 
 | |
| %Import core/core.sip
 | |
| %Include qgsserverexception.sip
 | |
| 
 | |
| %Feature HAVE_SERVER_PYTHON_PLUGINS
 | |
| 
 | |
| %Include server_auto.sip
 | |
| 
 | |
| 
 | |
| %VirtualErrorHandler serverapi_badrequest_exception_handler
 | |
|     PyObject *exception, *value, *traceback;
 | |
|     PyErr_Fetch(&exception, &value, &traceback);
 | |
|     SIP_RELEASE_GIL( sipGILState );
 | |
|     QString strVal = "API bad request error";
 | |
|     if ( value && PyUnicode_Check(value) )
 | |
|     {
 | |
|       Py_ssize_t size;
 | |
|       strVal = QString::fromUtf8( PyUnicode_AsUTF8AndSize(value, &size) );
 | |
|     }
 | |
|     throw QgsServerApiBadRequestException( strVal );
 | |
| %End
 | |
| 
 | |
| 
 | |
| %VirtualErrorHandler server_exception_handler
 | |
|     PyObject *exception, *value, *traceback;
 | |
|     PyErr_Fetch(&exception, &value, &traceback);
 | |
|     SIP_RELEASE_GIL( sipGILState );
 | |
|     QString strVal = "Server internal error";
 | |
|     if ( value && PyUnicode_Check(value) )
 | |
|     {
 | |
|       Py_ssize_t size;
 | |
|       strVal = QString::fromUtf8( PyUnicode_AsUTF8AndSize(value, &size) );
 | |
|     }
 | |
|     throw QgsServerException( strVal );
 | |
| %End
 |