Bug report #20193

DBManager fails to display error messages with virtual layers

Added by Regis Haubourg over 5 years ago. Updated over 5 years ago.

Status:Closed
Priority:High
Assignee:Alessandro Pasotti
Category:DB Manager
Affected QGIS version:3.3(master) Regression?:Yes
Operating System:ubuntu Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:28014

Description

In QGIS master, error messages when trying to work with virtual layers are no more catched.

IN QGIS 2.1, just issuing a wrong query like

SELECT *

returned a window with

Query preparation error on PRAGMA table_info(_tview): no tables specified

In QGIS master, this error window is empty.

History

#1 Updated by Regis Haubourg over 5 years ago

Also occurs in QGIS 3.2.2

#2 Updated by Alessandro Pasotti over 5 years ago

  • Assignee set to Alessandro Pasotti

#3 Updated by Giovanni Manghi over 5 years ago

as far as I remember it does not affect only virtual layers-

#4 Updated by Hugo Mercier over 5 years ago

From what I can see, there is at least the following problem:

bool QgsVirtualLayerTask::run()
{
  bool rc = false;
  try
  {
    mLayer->reload(); // blocking call because the loading is postponed
    rc = mLayer->isValid();
  }
  catch ( std::exception &e )
  {
    QgsDebugMsg( QStringLiteral( "Reload error: %1" ).arg( e.what() ) );
    rc = false;
  }
  return rc;
}

The error is catched and displayed in a QgsDebugMsg. It seems there is no way to set an error status on a qgstask ?

#5 Updated by Alessandro Pasotti over 5 years ago

  • Status changed from Open to In Progress
  • Pull Request or Patch supplied changed from No to Yes

#6 Updated by Alessandro Pasotti over 5 years ago

Sorry Hugo, I didn't see your comment before I made the PR.

Yes: there is no way to store an error message, that's why there is a wrapper for that in code: https://github.com/qgis/QGIS/blob/master/python/core/additions/qgstaskwrapper.py

I'm not sure what would be the best re-usable approach here but the bugfix I've implemented was exactly to add exceptionText to the task in order to store the error message.

#7 Updated by Hugo Mercier over 5 years ago

No problem :)

#8 Updated by Alessandro Pasotti over 5 years ago

  • Resolution set to fixed/implemented
  • Status changed from In Progress to Closed

Also available in: Atom PDF