diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-12-15 00:51:46 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-12-15 01:13:43 +0100 |
| commit | 244a24104ded3a4573aeffa32160af21f76cbce6 (patch) | |
| tree | f3a11529172719657cf7576e062e45e0f9452db5 /src/pipeline.cpp | |
| parent | 1e9894b0e2b161e61546672bccb85a9ef21df541 (diff) | |
| download | PROJ-244a24104ded3a4573aeffa32160af21f76cbce6.tar.gz PROJ-244a24104ded3a4573aeffa32160af21f76cbce6.zip | |
Revise error codes to have a reduced set exposed in the public API.
Fixes #2482
And also add proj_context_errno_string()
Revise gie 'expect failure errno XXXX' strings
Diffstat (limited to 'src/pipeline.cpp')
| -rw-r--r-- | src/pipeline.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/pipeline.cpp b/src/pipeline.cpp index e9d11604..6a46ebd8 100644 --- a/src/pipeline.cpp +++ b/src/pipeline.cpp @@ -96,7 +96,6 @@ Thomas Knudsen, thokn@sdfe.dk, 2016-05-20 #define PJ_LIB__ -#include <errno.h> #include <math.h> #include <stddef.h> #include <string.h> @@ -430,8 +429,8 @@ PJ *OPERATION(pipeline,0) { // proj=pipeline step "x="""," u=" proj=pipeline step ste=""[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline p step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ""x=""""""""""" // Probably an issue with the quoting handling code // But doesn't hurt to add an extra safety check - proj_log_error (P, "Pipeline: too deep recursion"); - return destructor (P, PJD_ERR_MALFORMED_PIPELINE); /* ERROR: nested pipelines */ + proj_log_error (P, _("Pipeline: too deep recursion")); + return destructor (P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); /* ERROR: nested pipelines */ } P->fwd4d = pipeline_forward_4d; @@ -453,24 +452,24 @@ PJ *OPERATION(pipeline,0) { P->opaque = new (std::nothrow) Pipeline(); if (nullptr==P->opaque) - return destructor(P, ENOMEM); + return destructor(P, PROJ_ERR_INVALID_OP /* ENOMEM */); argc = (int)argc_params (P->params); auto pipeline = static_cast<struct Pipeline*>(P->opaque); pipeline->argv = argv = argv_params (P->params, argc); if (nullptr==argv) - return destructor (P, ENOMEM); + return destructor (P, PROJ_ERR_INVALID_OP /* ENOMEM */); pipeline->current_argv = current_argv = static_cast<char**>(calloc (argc, sizeof (char *))); if (nullptr==current_argv) - return destructor (P, ENOMEM); + return destructor (P, PROJ_ERR_INVALID_OP /*ENOMEM*/); /* Do some syntactical sanity checking */ for (i = 0; i < argc; i++) { if (0==strcmp (argv_sentinel, argv[i])) { if (-1==i_pipeline) { - proj_log_error (P, "Pipeline: +step before +proj=pipeline"); - return destructor (P, PJD_ERR_MALFORMED_PIPELINE); + proj_log_error (P, _("Pipeline: +step before +proj=pipeline")); + return destructor (P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); } if (0==nsteps) i_first_step = i; @@ -480,8 +479,8 @@ PJ *OPERATION(pipeline,0) { if (0==strcmp ("proj=pipeline", argv[i])) { if (-1 != i_pipeline) { - proj_log_error (P, "Pipeline: Nesting only allowed when child pipelines are wrapped in '+init's"); - return destructor (P, PJD_ERR_MALFORMED_PIPELINE); /* ERROR: nested pipelines */ + proj_log_error (P, _("Pipeline: Nesting only allowed when child pipelines are wrapped in '+init's")); + return destructor (P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); /* ERROR: nested pipelines */ } i_pipeline = i; } @@ -489,10 +488,10 @@ PJ *OPERATION(pipeline,0) { nsteps--; /* Last instance of +step is just a sentinel */ if (-1==i_pipeline) - return destructor (P, PJD_ERR_MALFORMED_PIPELINE); /* ERROR: no pipeline def */ + return destructor (P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); /* ERROR: no pipeline def */ if (0==nsteps) - return destructor (P, PJD_ERR_MALFORMED_PIPELINE); /* ERROR: no pipeline def */ + return destructor (P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); /* ERROR: no pipeline def */ set_ellipsoid(P); @@ -532,8 +531,8 @@ PJ *OPERATION(pipeline,0) { /* The step init failed, but possibly without setting errno. If so, we say "malformed" */ int err_to_report = proj_errno(P); if (0==err_to_report) - err_to_report = PJD_ERR_MALFORMED_PIPELINE; - proj_log_error (P, "Pipeline: Bad step definition: %s (%s)", current_argv[0], proj_errno_string (err_to_report)); + err_to_report = PROJ_ERR_INVALID_OP_WRONG_SYNTAX; + proj_log_error (P, _("Pipeline: Bad step definition: %s (%s)"), current_argv[0], proj_context_errno_string (P->ctx, err_to_report)); return destructor (P, err_to_report); /* ERROR: bad pipeline def */ } next_step->parent = P; @@ -562,8 +561,8 @@ PJ *OPERATION(pipeline,0) { (!Q->inverted && (Q->fwd || Q->fwd3d || Q->fwd4d) ) ) { continue; } else { - proj_log_error (P, "Pipeline: A forward operation couldn't be constructed"); - return destructor (P, PJD_ERR_MALFORMED_PIPELINE); + proj_log_error (P, _("Pipeline: A forward operation couldn't be constructed")); + return destructor (P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); } } @@ -612,8 +611,8 @@ PJ *OPERATION(pipeline,0) { continue; if ( curr_step_output != next_step_input ) { - proj_log_error (P, "Pipeline: Mismatched units between step %d and %d", i+1, i+2); - return destructor (P, PJD_ERR_MALFORMED_PIPELINE); + proj_log_error (P, _("Pipeline: Mismatched units between step %d and %d"), i+1, i+2); + return destructor (P, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); } } @@ -682,7 +681,7 @@ static PJ *setup_pushpop(PJ *P) { auto pushpop = static_cast<struct PushPop*>(calloc (1, sizeof(struct PushPop))); P->opaque = pushpop; if (nullptr==P->opaque) - return destructor(P, ENOMEM); + return destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); if (pj_param_exists(P->params, "v_1")) pushpop->v1 = true; |
