[QGIS-Developer] Clear exception messages in algorithms

Olivier Dalang olivier.dalang at gmail.com
Thu May 30 15:31:05 PDT 2019


Thanks Nyall !

Maybe we could keep the log tab as is, but by default show another more
user-friendly "output" tab, which would just show the progress bar and
simple success/error messages (without trace). On error, the user would be
invited to inspect the log tab to see more details.

I'd find this really nice, as the processing toolbox is becoming more and
more central to QGIS, and the log tab is quite scary to look at even when
everything works fine :-)

If we agree on this, I can open a feature request (and will see if I can
get resources to work on a PR somehow...)

Cheers,

Olivier






On Fri, 31 May 2019 at 00:12, Nyall Dawson <nyall.dawson at gmail.com> wrote:

> On Wed, 29 May 2019 at 20:43, Olivier Dalang <olivier.dalang at gmail.com>
> wrote:
> >
> > Dear list,
> >
> > I'm currently developing a plugin that adds algorithms that query an
> API. There are some very clear issues that may arise, such as hitting an
> API quota limit.
> >
> > However, I couldn't find a way to provide clear error message to the
> user.
> >
> > This is what I have in my processAlgorithm(...) method :
> >
> > if limit_reached:
> > feedback.reportError("API usage limit reached", fatalError=True)
> > raise QgsProcessingException("API usage limit warning")
> >
> > It works well, but the error is hidden in the middle of a potentially
> long trace (see below) that is so cryptic for the typical user that he will
> miss the important message (which is "API usage limit reached").
> >
> > I tried to play a bit around with things like `raise QgsException(...)
> from None` or other things, but could find a way to provide better output
> for the user. And since it's from an algorithm, it's not possible to use
> iface.pushMessage() or any other UI mean to do so...
>
> There's no nice way to do this currently. I think we need to rework
> this a bit, and only show the full stacktrace for
> non-QgsProcessingException exceptions. That way we'd get the detailed
> error for Python mistakes, but we would also be able to skip it when
> it's not an unexpected error.
>
> Nyall
>
> >
> > Any pointer would be greatly appreciated !
> >
> > Cheers,
> >
> > Olivier
> >
> >
> >
> >
> > Example output log :
> >
> > Processing algorithm…
> >
> > Algorithm 'Time Map - Simple' starting…
> >
> > Input parameters:
> >
> > { 'INPUT_SEARCHES' :
> 'memory?geometry=Point&crs=EPSG:4326&field=full_id:string(0,0)&field=osm_id:string(0,0)&field=osm_type:string(0,0)&field=amenity:string(0,0)&field=name:string(0,0)&field=cuisine:string(0,0)&field=addr:housenumber:string(0,0)&field=addr:postcode:string(0,0)&field=addr:street:string(0,0)&field=diet:gluten_free:string(0,0)&field=diet:vegetarian:string(0,0)&field=phone:string(0,0)&field=wheelchair:string(0,0)&field=addr:city:string(0,0)&field=fhrs:id:string(0,0)&field=source:addr:string(0,0)&field=alt_name:string(0,0)&field=fhrs:authority:string(0,0)&field=fhrs:inspectiondate:string(0,0)&field=fhrs:rating:string(0,0)&field=addr:housename:string(0,0)&field=addr:unit:string(0,0)&field=dontimport:fhrs:addrline1:string(0,0)&field=dontimport:fhrs:addrline2:string(0,0)&field=dontimport:fhrs:businesstype:string(0,0)&field=opening_hours:string(0,0)&field=email:string(0,0)&field=website:string(0,0)&field=contact:phone:string(0,0)&field=wheelchair:description:string(0,0)&field=toilets:wheelchair:string(0,0)&field=toilets:string(0,0)&field=toilets:access:string(0,0)&field=opening_hours:url:string(0,0)&field=takeaway:string(0,0)&field=fhrs:confidence_management:string(0,0)&field=fhrs:hygiene:string(0,0)&field=fhrs:local_authority_id:string(0,0)&field=fhrs:structural:string(0,0)&field=outdoor_seating:string(0,0)&field=source:postcode:string(0,0)&field=wikidata:string(0,0)&field=payment:american_express:string(0,0)&field=old_name:string(0,0)&field=source:addr:postcode:string(0,0)&field=diet:raw:string(0,0)&field=diet:vegan:string(0,0)&field=facebook:string(0,0)&field=warning:string(0,0)&field=currency:XLT:string(0,0)&field=payment:cash:XLT-BXTP:string(0,0)&field=payment:text:XLT-BXTP:string(0,0)&field=postal_code:string(0,0)&field=addr:country:string(0,0)&field=brand:string(0,0)&field=brand:wikidata:string(0,0)&field=brand:wikipedia:string(0,0)&field=contact:website:string(0,0)&field=capacity:string(0,0)&field=operator:string(0,0)&field=smoking:string(0,0)&field=level:string(0,0)&field=postcode:string(0,0)&field=layer:string(0,0)&field=delivery:string(0,0)&field=contact:email:string(0,0)&field=addr:floor:string(0,0)&field=description:floor:string(0,0)&field=old_fhrs:id:string(0,0)&field=old_fhrs:local_authority_id:string(0,0)&field=addr:suburb:string(0,0)&field=wifi:string(0,0)&field=drive_in:string(0,0)&field=microbrewery:string(0,0)&field=branch:string(0,0)&field=tourism:string(0,0)&field=note:name:ko:string(0,0)&field=wikipedia:string(0,0)&field=name:en:string(0,0)&field=url:string(0,0)&field=name:zh:string(0,0)&field=old_cuisine:string(0,0)&field=diet:pescetarian:string(0,0)&field=seats:string(0,0)&field=bar:string(0,0)&field=type:string(0,0)&field=former_name:string(0,0)&field=food:string(0,0)&field=disused:string(0,0)&field=operator:wikidata:string(0,0)&field=disused:name:string(0,0)&field=addr:place:string(0,0)&field=contact:fax:string(0,0)&field=fax:string(0,0)&field=note:name:en:string(0,0)&field=note:name:zh:string(0,0)&field=alcohol:string(0,0)&field=entrance:string(0,0)&field=internet_access:fee:string(0,0)&field=brewery:string(0,0)&field=note:name:string(0,0)&field=instagram:string(0,0)&field=twitter:string(0,0)&field=building:level:string(0,0)&field=internet_access:string(0,0)&field=description:string(0,0)&field=trendy:string(0,0)&field=colour:string(0,0)&field=erected_by:string(0,0)&field=historic:string(0,0)&field=inscription:string(0,0)&field=memorial:string(0,0)&field=openplaques:id:string(0,0)&field=scheme:string(0,0)&field=addr:full:string(0,0)&field=number:string(0,0)&field=contact:twitter:string(0,0)&field=name:es:string(0,0)&field=name:gl:string(0,0)&field=uri:string(0,0)&field=indoor_seating:string(0,0)&field=music:string(0,0)&field=product:string(0,0)&field=contact:facebook:string(0,0)&field=ref:NPLG:UPRN:1:string(0,0)&field=drink:coffee:string(0,0)&field=drink:soft_drink:string(0,0)&field=drink:tea:string(0,0)&field=source:name:string(0,0)&field=wikimedia_commons:string(0,0)&field=access:string(0,0)&field=barrier:string(0,0)&field=building:string(0,0)&field=payment:bitcoin:string(0,0)&field=start_date:string(0,0)&field=shop:units:string(0,0)&field=source:position:string(0,0)&field=survey:date:string(0,0)&field=payment:cash:string(0,0)&field=payment:credit_cards:string(0,0)&field=payment:debit_cards:string(0,0)&field=camera:mount:string(0,0)&field=camera:type:string(0,0)&field=man_made:string(0,0)&field=surveillance:string(0,0)&field=surveillance:type:string(0,0)&field=surveillance:zone:string(0,0)&field=disused:amenity:string(0,0)&field=shop:string(0,0)&field=checkfirst:suggested:name:string(0,0)&field=source:date:string(0,0)&field=addr:interpolation:string(0,0)&field=diet:halal:string(0,0)&field=note_1:string(0,0)&field=designation:string(0,0)&field=addr:flat:string(0,0)&field=addr:flats:string(0,0)&field=organic:string(0,0)&field=memorial:type:string(0,0)&field=max_level:string(0,0)&field=min_level:string(0,0)&field=fhrs:name:string(0,0)&field=diet:string(0,0)&field=construction:string(0,0)&field=old_amenity:string(0,0)&field=happycow:id:string(0,0)&field=drive_through:string(0,0)&field=contact:instagram:string(0,0)&field=payment:mastercard:string(0,0)&field=payment:visa:string(0,0)&field=drink:wine:string(0,0)&field=payment:jcb:string(0,0)&field=contact:google_plus:string(0,0)&field=name:gsw:string(0,0)&field=drink:cider:string(0,0)&field=reservation:string(0,0)&field=name:ru:string(0,0)&field=name:nl:string(0,0)&field=name:lt:string(0,0)&field=name:ja:string(0,0)&field=name:ar:string(0,0)&field=name:it:string(0,0)&field=website:en:string(0,0)&field=name:pt:string(0,0)&field=amenity_1:string(0,0)&field=self_service:string(0,0)&field=highway:string(0,0)&field=lamp_mount:string(0,0)&field=name:pl:string(0,0)&field=stars:string(0,0)&field=drink:beer:string(0,0)&field=drink:lemonade:string(0,0)&field=drink:water:string(0,0)&field=breakfast:string(0,0)&field=drink:natural_wine:string(0,0)&field=name:ro:string(0,0)&field=drink:cola:string(0,0)&field=disused:shop:string(0,0)&field=not:addr:postcode:string(0,0)&field=source:addr:housenumber:string(0,0)&field=camera:direction:string(0,0)&field=real_ale:string(0,0)&field=not:addr:street:string(0,0)&field=baby_change:string(0,0)&field=name:fr:string(0,0)&field=automatic_door:string(0,0)&field=door:string(0,0)&field=serves_cars:bool(0,0)&field=is_drive_through:bool(0,0)&uid={98191443-a039-467a-a0c6-4dbfb08707cf}',
> 'INPUT_SEARCH_TYPE' : 0, 'INPUT_TIME' : '2019-05-29T12:00:00',
> 'INPUT_TRAVEL_TIME' : 15, 'INPUT_TRNSPT_TYPE' : 0, 'OUTPUT' : 'memory:',
> 'OUTPUT_RESULT_TYPE' : 0 }
> >
> >
> > Starting TimeMapSimpleAlgorithm...
> >
> > Calling subcommand with following parameters...
> >
> > {'INPUT_DEPARTURE_SEARCHES': <qgis._core.QgsVectorLayer object at
> 0x00000249EB1ADCA8>, 'INPUT_DEPARTURE_TRNSPT_TYPE': "'cycling'",
> 'INPUT_DEPARTURE_TIME': "'2019-05-29T12:00:00'", 'OUTPUT_RESULT_TYPE': 0,
> 'OUTPUT': 'memory:results', 'INPUT_DEPARTURE_TRAVEL_TIME': '900',
> 'INPUT_DEPARTURE_TRNSPT_WALKING_TIME': '900'}
> >
> > Starting TimeMapAlgorithm...
> >
> > Checking API limit warnings...
> >
> > API usage limit reached !
> >
> > Traceback (most recent call last):
> > File
> "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\advanced.py",
> line 383, in processAlgorithm
> > slices = self.processAlgorithmGetSlices(parameters, context, feedback)
> > File
> "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\advanced.py",
> line 234, in processAlgorithmGetSlices
> > self.processAlgorithmEnforceLimit(len(slices), parameters, context,
> feedback)
> > File
> "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\base.py",
> line 245, in processAlgorithmEnforceLimit
> > raise QgsProcessingException("API usage limit reached ") from None
> > _core.QgsProcessingException: API usage limit reached
> >
> > There were errors executing the algorithm.
> >
> > Traceback (most recent call last):
> > File
> "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\simple.py",
> line 111, in processAlgorithm
> > sub_id, sub_parameters, context=context, feedback=feedback
> > File
> "C:/OSGEO4~1/apps/qgis-ltr/./python/plugins\processing\tools\general.py",
> line 105, in run
> > return Processing.runAlgorithm(algOrName, parameters, onFinish,
> feedback, context)
> > File
> "C:/OSGEO4~1/apps/qgis-ltr/./python/plugins\processing\core\Processing.py",
> line 183, in runAlgorithm
> > raise QgsProcessingException(msg)
> > _core.QgsProcessingException: There were errors executing the algorithm.
> >
> > Execution failed after 0.16 seconds
> >
> >
> > Loading resulting layers
> >
> > Algorithm 'Time Map - Simple' finished
> >
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190531/d201f6e4/attachment-0001.html>


More information about the QGIS-Developer mailing list