General exception handling
Within your code, you can use an exception called QvxPleaseSendReplyException(QvxResult result, string message). QvxResult should be one of those specified in the QVX file format.
When throwing a QvxPleaseSendReplyException, QvxLibrary catches it and sends a QvxReply to QlikView or Qlik Sense containing the specified result and message.
The following code example, taken from QvEventLogConnection.cs within the QvEventLogConnectorElaborate example connector, shows a typical throwing of a QvxPleaseSendReplyException:
private IEnumerable<QvxDataRow> GetEvents(string log, string tableName)
{
//...
if (EventLog.Exists(tableName))
{
throw new QvxPleaseSendReplyException(QvxResult.QVX_TABLE_NOT_FOUND,
String.Format("There is no EventLog with name: {0}", tableName));
}
// ...
}
When QlikView or Qlik Sense receives the QvxReply, it displays a message box similar to the following one:
When your application throws an exception other than QvxPleaseSendReplyException, QvxLibrary catches it and does two things:
- First, it writes the stack trace for the exception to a file called “StackTrace.txt”, which is located in the same folder as the log file.
- Then QvxLibrary sends a QvxReply to QlikView or Qlik Sense with result set to QVX_UNKNOWN_ERROR and message set to the ErrorMessage of the thrown exception.