Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QgsDistanceArea methods should raise QgsCsException when errors occur #58795

Merged
merged 1 commit into from
Sep 21, 2024

Conversation

nyalldawson
Copy link
Collaborator

Instead of just silently return "0", which is misleading and can result in data corruption/incorrect analysis results. Better to be safe and force callers to handle transformation errors appropriately.

In this case we:

  • raise QgsProcessingExceptions when the failed measurement is coming from a processing tool, so that the user is forced to deal with the issue and we aren't providing meaningless/misleading measurements
  • report evaluation errors if the measurement is coming from a QGIS expression, so the user must appropriately handle the situation
  • for all other cases we currently just write a console error and maintain the current behavior of treating the measurement length as 0. TODO notes have been added to handle this cases better.

Instead of just silently return "0", which is misleading and
can result in data corruption/incorrect analysis results. Better
to be safe and force callers to handle transformation errors
appropriately.

In this case we:

- raise QgsProcessingExceptions when the failed measurement is coming
from a processing tool, so that the user is forced to deal with the
issue and we aren't providing meaningless/misleading measurements
- report evaluation errors if the measurement is coming from a
QGIS expression, so the user must appropriately handle the situation
- for all other cases we currently just write a console error and
maintain the current behavior of treating the measurement length
as 0. TODO notes have been added to handle this cases better.
@github-actions github-actions bot added this to the 3.40.0 milestone Sep 18, 2024
Copy link

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit ba80cd4)

}
catch ( QgsCsException & )
{
// TODO report errors to user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of some (all of) those TODOs? here for instance, we have access to QgisApp visibleMessageBar()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy for someone else to do that, but right now it's not my priority. There's no regression here at least, the behaviour will be identical to current behaviour

@uclaros
Copy link
Contributor

uclaros commented Sep 20, 2024

Plugins might crash with an unhandled exception though. Should we somehow advertise this change to plugin developers? Mailing list? Other means?

@nyalldawson
Copy link
Collaborator Author

@uclaros

Plugins might crash with an unhandled exception though.

I realise that, but I think that's preferable to this API silently giving incorrect measurements. At least this way the plugin authors will be advised and make the decision themselves on the best way to handle this situation.

Should we somehow advertise this change to plugin developers? Mailing list? Other means?

This kind of thing usually goes into the PyQGIS part of the changelog

@nyalldawson nyalldawson added the Changelog Items that are queued to appear in the visual changelog - remove after harvesting label Sep 20, 2024
@qgis-bot
Copy link
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@nyalldawson nyalldawson merged commit cde770e into qgis:master Sep 21, 2024
35 checks passed
@nyalldawson nyalldawson deleted the da_exception branch September 21, 2024 22:23
@zacharlie zacharlie added ChangelogHarvested This PR description has been harvested in the Changelog already. and removed Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChangelogHarvested This PR description has been harvested in the Changelog already.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants