<div dir="ltr">Thanks Nyall !<br><div><br></div><div>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.</div><div><br></div><div>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 :-)</div><div><br></div><div>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...)</div><div><br></div><div>Cheers,</div><div><br></div><div>Olivier</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 31 May 2019 at 00:12, Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 29 May 2019 at 20:43, Olivier Dalang <<a href="mailto:olivier.dalang@gmail.com" target="_blank">olivier.dalang@gmail.com</a>> wrote:<br>
><br>
> Dear list,<br>
><br>
> 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.<br>
><br>
> However, I couldn't find a way to provide clear error message to the user.<br>
><br>
> This is what I have in my processAlgorithm(...) method :<br>
><br>
> if limit_reached:<br>
> feedback.reportError("API usage limit reached", fatalError=True)<br>
> raise QgsProcessingException("API usage limit warning")<br>
><br>
> 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").<br>
><br>
> 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...<br>
<br>
There's no nice way to do this currently. I think we need to rework<br>
this a bit, and only show the full stacktrace for<br>
non-QgsProcessingException exceptions. That way we'd get the detailed<br>
error for Python mistakes, but we would also be able to skip it when<br>
it's not an unexpected error.<br>
<br>
Nyall<br>
<br>
><br>
> Any pointer would be greatly appreciated !<br>
><br>
> Cheers,<br>
><br>
> Olivier<br>
><br>
><br>
><br>
><br>
> Example output log :<br>
><br>
> Processing algorithm…<br>
><br>
> Algorithm 'Time Map - Simple' starting…<br>
><br>
> Input parameters:<br>
><br>
> { '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 }<br>
><br>
><br>
> Starting TimeMapSimpleAlgorithm...<br>
><br>
> Calling subcommand with following parameters...<br>
><br>
> {'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'}<br>
><br>
> Starting TimeMapAlgorithm...<br>
><br>
> Checking API limit warnings...<br>
><br>
> API usage limit reached !<br>
><br>
> Traceback (most recent call last):<br>
> File "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\advanced.py", line 383, in processAlgorithm<br>
> slices = self.processAlgorithmGetSlices(parameters, context, feedback)<br>
> File "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\advanced.py", line 234, in processAlgorithmGetSlices<br>
> self.processAlgorithmEnforceLimit(len(slices), parameters, context, feedback)<br>
> File "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\base.py", line 245, in processAlgorithmEnforceLimit<br>
> raise QgsProcessingException("API usage limit reached ") from None<br>
> _core.QgsProcessingException: API usage limit reached<br>
><br>
> There were errors executing the algorithm.<br>
><br>
> Traceback (most recent call last):<br>
> File "C:/Users/Olivier/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\travel_time_platform_plugin\algorithms\simple.py", line 111, in processAlgorithm<br>
> sub_id, sub_parameters, context=context, feedback=feedback<br>
> File "C:/OSGEO4~1/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 105, in run<br>
> return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)<br>
> File "C:/OSGEO4~1/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 183, in runAlgorithm<br>
> raise QgsProcessingException(msg)<br>
> _core.QgsProcessingException: There were errors executing the algorithm.<br>
><br>
> Execution failed after 0.16 seconds<br>
><br>
><br>
> Loading resulting layers<br>
><br>
> Algorithm 'Time Map - Simple' finished<br>
><br>
> _______________________________________________<br>
> QGIS-Developer mailing list<br>
> <a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>