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

Make sure that transient errors are returned correctly #857

Merged
merged 3 commits into from Mar 12, 2018

Conversation

kbevers
Copy link
Member

@kbevers kbevers commented Mar 11, 2018

The prepare/finalize steps in pj_fwd*/pj_inv* now checks the error level
of the PJ object before returning the coordinate. If an error is
detected proj_coord_error() is returned.

Prompted by pytroll/mpop#49 (comment)

The prepare/finalize steps in pj_fwd*/pj_inv* now checks the error level
of the PJ object before returning the coordinate. If an error is
detected proj_coord_error() is returned.
src/pj_fwd.c Outdated
static PJ_COORD error_or_coord(PJ *P, PJ_COORD coord, int last_errno) {
if (proj_errno(P))
coord = proj_coord_error();
else
Copy link
Member

Choose a reason for hiding this comment

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

Could handle the non-common case by if (...) return proj_coord_error() here.

This would raise the common case to top level, rather than partially depressed behind an else clause


XY pj_fwd(LP lp, PJ *P) {
int last_errno;
PJ_COORD coo = {{0,0,0,0}};
coo.lp = lp;
Copy link
Member

Choose a reason for hiding this comment

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

It is tempting, at this stage, to consider whether we want to play ball at all if there's an unhandled exception - i.e. just do

if (proj_errno(P))
    return proj_coord_error();

It will, however, require some additional error handling in the pj_transform(), and the proj_trans...()family, to avoid an error for a single point (e.g. out of area) to result in all subsequent points in that call failing.

(this comment also applies to pj_fwd3d, pj_fwd4d, and their invcounterparts).

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a problem for another day :-)

Copy link
Member

Choose a reason for hiding this comment

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

:-)

@kbevers kbevers force-pushed the return-error-instead-of-zeros branch from a077a1c to 22203cc Compare March 12, 2018 11:17
@kbevers kbevers added this to the 5.0.1 milestone Mar 12, 2018
@kbevers kbevers merged commit d422d45 into OSGeo:master Mar 12, 2018
kbevers added a commit that referenced this pull request Mar 12, 2018
Make sure that transient errors are returned correctly
@kbevers
Copy link
Member Author

kbevers commented Mar 12, 2018

Cherry-picked into 5.0 branch

@kbevers kbevers deleted the return-error-instead-of-zeros branch March 12, 2018 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants