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

Error management: revise error codes and expose them to the public API #2487

Merged
merged 11 commits into from
Dec 16, 2020

Conversation

rouault
Copy link
Member

@rouault rouault commented Dec 15, 2020

Fixes #2482

Three classes of errors are defined:


/** Error codes typically related to coordinate operation initalization
 * Note: some of them can also be emitted during coordinate transformation,
 * like PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID in case the resource loading
 * is differed until it is really needed.
 */
#define PROJ_ERR_INVALID_OP                           1024                        /* other/unspecified error related to coordinate operation initialization */
#define PROJ_ERR_INVALID_OP_WRONG_SYNTAX              (PROJ_ERR_INVALID_OP+1)     /* invalid pipeline structure, missing +proj argument, etc */
#define PROJ_ERR_INVALID_OP_MISSING_ARG               (PROJ_ERR_INVALID_OP+2)     /* missing required operation parameter */
#define PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE         (PROJ_ERR_INVALID_OP+3)     /* one of the operation parameter has an illegal value */
#define PROJ_ERR_INVALID_OP_MUTUALLY_EXCLUSIVE_ARGS   (PROJ_ERR_INVALID_OP+4)     /* mutually exclusive arguments */
#define PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID (PROJ_ERR_INVALID_OP+5)     /* file not found (particular case of PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE) */

/** Error codes related to transformation on a specific coordinate */
#define PROJ_ERR_COORD_TRANSFM                           2048                           /* other error related to coordinate transformation */
#define PROJ_ERR_COORD_TRANSFM_INVALID_COORD             (PROJ_ERR_COORD_TRANSFM+1)     /* for e.g lat > 90deg */
#define PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN (PROJ_ERR_COORD_TRANSFM+2)     /* coordinate is outside of the projection domain. e.g approximate mercator with |longitude - lon_0| > 90deg, or iterative convergence method failed */
#define PROJ_ERR_COORD_TRANSFM_NO_OPERATION              (PROJ_ERR_COORD_TRANSFM+3)     /* no operation found, e.g if no match the required accuracy, or if ballpark transformations were asked to not be used and they would be only such candidate */
#define PROJ_ERR_COORD_TRANSFM_OUTSIDE_GRID              (PROJ_ERR_COORD_TRANSFM+4)     /* point to transform falls outside grid or subgrid */
#define PROJ_ERR_COORD_TRANSFM_GRID_AT_NODATA            (PROJ_ERR_COORD_TRANSFM+5)     /* point to transform falls in a grid cell that evaluates to nodata */

/** Other type of errors */
#define PROJ_ERR_OTHER                                   4096
#define PROJ_ERR_OTHER_API_MISUSE                        (PROJ_ERR_OTHER+1)             /* error related to a misuse of PROJ API */
#define PROJ_ERR_OTHER_NO_INVERSE_OP                     (PROJ_ERR_OTHER+2)             /* no inverse method available */
#define PROJ_ERR_OTHER_NETWORK_ERROR                     (PROJ_ERR_OTHER+3)             /* failure when accessing a network resource */

And also add proj_context_errno_string()

Revise gie 'expect failure errno XXXX' strings

Other related changes:

  • Move proj_log_XXX() functions from internal.cpp to log.cpp
  • Remove ancient no longer used implementation of pj_ell_set()
  • tmerc exact: set errno to PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN when it returns invalid coordinate
  • proj_trans_array(): make it transform all coordinates even when an error occurs

@rouault rouault added this to the 8.0.0 milestone Dec 15, 2020
Copy link
Member

@kbevers kbevers left a comment

Choose a reason for hiding this comment

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

There's a lot go through here. For this initial review I've only added a few comments in the start. Some of them will be relevant throughout the PR since they are a bit fundamental to how errors and loggin should be handled.

God job so far. It's a big project to change all of this to the better!

docs/source/development/reference/functions.rst Outdated Show resolved Hide resolved
docs/source/development/reference/functions.rst Outdated Show resolved Hide resolved
docs/source/development/reference/functions.rst Outdated Show resolved Hide resolved
src/4D_api.cpp Outdated Show resolved Hide resolved
src/apps/gie.cpp Show resolved Hide resolved
src/conversions/axisswap.cpp Outdated Show resolved Hide resolved
@rouault rouault force-pushed the error_mgt_improvements branch from cc0ec69 to 4f1002a Compare December 15, 2020 14:32
src/log.cpp Outdated Show resolved Hide resolved
src/log.cpp Show resolved Hide resolved
@rouault rouault force-pushed the error_mgt_improvements branch from bd7bc5c to 41c4e54 Compare December 15, 2020 16:25
@rouault
Copy link
Member Author

rouault commented Dec 16, 2020

@kbevers Do you wish to review more things in this PR ?

@kbevers
Copy link
Member

kbevers commented Dec 16, 2020

No, I think this looks good as it is!

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.

Exposing PJD_ERR codes to the public API ?
2 participants