From 244a24104ded3a4573aeffa32160af21f76cbce6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 15 Dec 2020 00:51:46 +0100 Subject: 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 --- src/transformations/affine.cpp | 4 +-- src/transformations/defmodel.cpp | 22 +++++++-------- src/transformations/deformation.cpp | 32 ++++++++++----------- src/transformations/helmert.cpp | 32 ++++++++++++--------- src/transformations/hgridshift.cpp | 8 +++--- src/transformations/horner.cpp | 50 ++++++++++++++++++++++++--------- src/transformations/molodensky.cpp | 54 +++++++++++++++++++----------------- src/transformations/tinshift.cpp | 20 ++++++------- src/transformations/vgridshift.cpp | 8 +++--- src/transformations/xyzgridshift.cpp | 14 +++++----- 10 files changed, 138 insertions(+), 106 deletions(-) (limited to 'src/transformations') diff --git a/src/transformations/affine.cpp b/src/transformations/affine.cpp index 43fd8642..8b927688 100644 --- a/src/transformations/affine.cpp +++ b/src/transformations/affine.cpp @@ -176,7 +176,7 @@ static void computeReverseParameters(PJ* P) PJ *TRANSFORMATION(affine,0 /* no need for ellipsoid */) { struct pj_opaque_affine *Q = initQ(); if (nullptr==Q) - return pj_default_destructor(P, ENOMEM); + return pj_default_destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); P->opaque = (void *) Q; P->fwd4d = forward_4d; @@ -227,7 +227,7 @@ PJ *TRANSFORMATION(affine,0 /* no need for ellipsoid */) { PJ *TRANSFORMATION(geogoffset,0 /* no need for ellipsoid */) { struct pj_opaque_affine *Q = initQ(); if (nullptr==Q) - return pj_default_destructor(P, ENOMEM); + return pj_default_destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); P->opaque = (void *) Q; P->fwd4d = forward_4d; diff --git a/src/transformations/defmodel.cpp b/src/transformations/defmodel.cpp index 3d0f2a58..89e0429f 100644 --- a/src/transformations/defmodel.cpp +++ b/src/transformations/defmodel.cpp @@ -390,7 +390,7 @@ PJ *TRANSFORMATION(defmodel, 1) { // Pass a dummy ellipsoid definition that will be overridden just afterwards auto cart = proj_create(P->ctx, "+proj=cart +a=1"); if (cart == nullptr) - return destructor(P, ENOMEM); + return destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); /* inherit ellipsoid definition from P to Q->cart */ pj_inherit_ellipsoid_def(P, cart); @@ -402,14 +402,14 @@ PJ *TRANSFORMATION(defmodel, 1) { const char *model = pj_param(P->ctx, P->params, "smodel").s; if (!model) { - proj_log_error(P, "defmodel: +model= should be specified."); - return destructor(P, PJD_ERR_NO_ARGS); + proj_log_error(P, _("defmodel: +model= should be specified.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } auto file = NS_PROJ::FileManager::open_resource_file(P->ctx, model); if (nullptr == file) { - proj_log_error(P, "defmodel: Cannot open %s", model); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("defmodel: Cannot open %s"), model); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } file->seek(0, SEEK_END); unsigned long long size = file->tell(); @@ -417,23 +417,23 @@ PJ *TRANSFORMATION(defmodel, 1) { // that could be a denial of service risk. 10 MB should be sufficiently // large for any valid use ! if (size > 10 * 1024 * 1024) { - proj_log_error(P, "defmodel: File %s too large", model); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("defmodel: File %s too large"), model); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } file->seek(0); std::string jsonStr; jsonStr.resize(static_cast(size)); if (file->read(&jsonStr[0], jsonStr.size()) != jsonStr.size()) { - proj_log_error(P, "defmodel: Cannot read %s", model); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("defmodel: Cannot read %s"), model); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } try { Q->evaluator.reset(new Evaluator( MasterFile::parse(jsonStr), Q->evaluatorIface, P->a, P->b)); } catch (const std::exception &e) { - proj_log_error(P, "defmodel: invalid model: %s", e.what()); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("defmodel: invalid model: %s"), e.what()); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } P->fwd4d = forward_4d; diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index 8ce02bee..307de85f 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -179,7 +179,7 @@ static PJ_XYZ get_grid_shift(PJ* P, const PJ_XYZ& cartesian) { shift.lp = pj_hgrid_value(P, Q->hgrids, geodetic.lp); shift.enu.u = pj_vgrid_value(P, Q->vgrids, geodetic.lp, 1.0); - if (proj_errno(P) == PJD_ERR_GRID_AREA) + if (proj_errno(P) == PROJ_ERR_COORD_TRANSFM_OUTSIDE_GRID) proj_log_debug(P, "deformation: coordinate (%.3f, %.3f) outside deformation model", proj_todeg(geodetic.lpz.lam), proj_todeg(geodetic.lpz.phi)); @@ -358,7 +358,7 @@ PJ *TRANSFORMATION(deformation,1) { // Pass a dummy ellipsoid definition that will be overridden just afterwards Q->cart = proj_create(P->ctx, "+proj=cart +a=1"); if (Q->cart == nullptr) - return destructor(P, ENOMEM); + return destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); /* inherit ellipsoid definition from P to Q->cart */ pj_inherit_ellipsoid_def (P, Q->cart); @@ -369,8 +369,8 @@ PJ *TRANSFORMATION(deformation,1) { /* Build gridlists. Both horizontal and vertical grids are mandatory. */ if ( !has_grids && (!has_xy_grids || !has_z_grids)) { - proj_log_error(P, "deformation: Either +grids or (+xy_grids and +z_grids) should be specified."); - return destructor(P, PJD_ERR_NO_ARGS ); + proj_log_error(P, _("deformation: Either +grids or (+xy_grids and +z_grids) should be specified.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG ); } if( has_grids ) @@ -378,22 +378,22 @@ PJ *TRANSFORMATION(deformation,1) { Q->grids = pj_generic_grid_init(P, "grids"); /* Was gridlist compiled properly? */ if ( proj_errno(P) ) { - proj_log_error(P, "deformation: could not find required grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("deformation: could not find required grid(s).)")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } } else { Q->hgrids = pj_hgrid_init(P, "xy_grids"); if (proj_errno(P)) { - proj_log_error(P, "deformation: could not find requested xy_grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("deformation: could not find requested xy_grid(s).")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } Q->vgrids = pj_vgrid_init(P, "z_grids"); if (proj_errno(P)) { - proj_log_error(P, "deformation: could not find requested z_grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("deformation: could not find requested z_grid(s).")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } } @@ -403,8 +403,8 @@ PJ *TRANSFORMATION(deformation,1) { } if (pj_param_exists(P->params, "t_obs")) { - proj_log_error(P, "deformation: +t_obs parameter is deprecated. Use +dt instead."); - return destructor(P, PJD_ERR_MISSING_ARGS); + proj_log_error(P, _("deformation: +t_obs parameter is deprecated. Use +dt instead.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } Q->t_epoch = HUGE_VAL; @@ -413,13 +413,13 @@ PJ *TRANSFORMATION(deformation,1) { } if (Q->dt == HUGE_VAL && Q->t_epoch == HUGE_VAL) { - proj_log_error(P, "deformation: either +dt or +t_epoch needs to be set."); - return destructor(P, PJD_ERR_MISSING_ARGS); + proj_log_error(P, _("deformation: either +dt or +t_epoch needs to be set.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } if (Q->dt != HUGE_VALL && Q->t_epoch != HUGE_VALL) { - proj_log_error(P, "deformation: +dt or +t_epoch are mutually exclusive."); - return destructor(P, PJD_ERR_MUTUALLY_EXCLUSIVE_ARGS); + proj_log_error(P, _("deformation: +dt or +t_epoch are mutually exclusive.")); + return destructor(P, PROJ_ERR_INVALID_OP_MUTUALLY_EXCLUSIVE_ARGS); } P->fwd4d = forward_4d; diff --git a/src/transformations/helmert.cpp b/src/transformations/helmert.cpp index 99aa74a4..edb85355 100644 --- a/src/transformations/helmert.cpp +++ b/src/transformations/helmert.cpp @@ -478,7 +478,7 @@ static PJ_COORD helmert_reverse_4d (PJ_COORD point, PJ *P) { static PJ* init_helmert_six_parameters(PJ* P) { struct pj_opaque_helmert *Q = static_cast(calloc (1, sizeof (struct pj_opaque_helmert))); if (nullptr==Q) - return pj_default_destructor (P, ENOMEM); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP /*ENOMEM*/); P->opaque = (void *) Q; /* In most cases, we work on 3D cartesian coordinates */ @@ -522,8 +522,8 @@ static PJ* read_convention(PJ* P) { if (!Q->no_rotation) { const char* convention = pj_param (P->ctx, P->params, "sconvention").s; if( !convention ) { - proj_log_error (P, "helmert: missing 'convention' argument"); - return pj_default_destructor (P, PJD_ERR_MISSING_ARGS); + proj_log_error (P, _("helmert: missing 'convention' argument")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } if( strcmp(convention, "position_vector") == 0 ) { Q->is_position_vector = 1; @@ -532,17 +532,17 @@ static PJ* read_convention(PJ* P) { Q->is_position_vector = 0; } else { - proj_log_error (P, "helmert: invalid value for 'convention' argument"); - return pj_default_destructor (P, PJD_ERR_INVALID_ARG); + proj_log_error (P, _("helmert: invalid value for 'convention' argument")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); } /* historically towgs84 in PROJ has always been using position_vector * convention. Accepting coordinate_frame would be confusing. */ if (pj_param_exists (P->params, "towgs84")) { if( !Q->is_position_vector ) { - proj_log_error (P, "helmert: towgs84 should only be used with " - "convention=position_vector"); - return pj_default_destructor (P, PJD_ERR_INVALID_ARG); + proj_log_error (P, _("helmert: towgs84 should only be used with " + "convention=position_vector")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); } } } @@ -578,9 +578,9 @@ PJ *TRANSFORMATION(helmert, 0) { /* Detect obsolete transpose flag and error out if found */ if (pj_param (P->ctx, P->params, "ttranspose").i) { - proj_log_error (P, "helmert: 'transpose' argument is no longer valid. " - "Use convention=position_vector/coordinate_frame"); - return pj_default_destructor (P, PJD_ERR_INVALID_ARG); + proj_log_error (P, _("helmert: 'transpose' argument is no longer valid. " + "Use convention=position_vector/coordinate_frame")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); } /* Support the classic PROJ towgs84 parameter, but allow later overrides.*/ @@ -612,9 +612,15 @@ PJ *TRANSFORMATION(helmert, 0) { if (pj_param (P->ctx, P->params, "ts").i) { Q->scale_0 = pj_param (P->ctx, P->params, "ds").f; if( Q->scale_0 <= -1.0e6 ) - return pj_default_destructor (P, PJD_ERR_INVALID_SCALE); + { + proj_log_error (P, _("helmert: invalid value for s.")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); + } if (pj_param (P->ctx, P->params, "ttheta").i && Q->scale_0 == 0.0) - return pj_default_destructor (P, PJD_ERR_INVALID_SCALE); + { + proj_log_error (P, _("helmert: invalid value for s.")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); + } } /* Translation rates */ diff --git a/src/transformations/hgridshift.cpp b/src/transformations/hgridshift.cpp index b28eaf48..1b2ff9b1 100644 --- a/src/transformations/hgridshift.cpp +++ b/src/transformations/hgridshift.cpp @@ -155,8 +155,8 @@ PJ *TRANSFORMATION(hgridshift,0) { P->right = PJ_IO_UNITS_RADIANS; if (0==pj_param(P->ctx, P->params, "tgrids").i) { - proj_log_error(P, "hgridshift: +grids parameter missing."); - return destructor (P, PJD_ERR_NO_ARGS); + proj_log_error(P, _("hgridshift: +grids parameter missing.")); + return destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } /* TODO: Refactor into shared function that can be used */ @@ -194,8 +194,8 @@ PJ *TRANSFORMATION(hgridshift,0) { Q->grids = pj_hgrid_init(P, "grids"); /* Was gridlist compiled properly? */ if ( proj_errno(P) ) { - proj_log_error(P, "hgridshift: could not find required grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("hgridshift: could not find required grid(s).")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } gMutex.lock(); diff --git a/src/transformations/horner.cpp b/src/transformations/horner.cpp index 2c049186..d88ea152 100644 --- a/src/transformations/horner.cpp +++ b/src/transformations/horner.cpp @@ -460,12 +460,12 @@ PJ *PROJECTION(horner) { degree = pj_param(P->ctx, P->params, "ideg").i; if (degree < 0 || degree > 10000) { /* What are reasonable minimum and maximums for degree? */ - proj_log_debug (P, "Horner: Degree is unreasonable: %d", degree); - return horner_freeup (P, PJD_ERR_INVALID_ARG); + proj_log_error (P, _("Horner: Degree is unreasonable: %d"), degree); + return horner_freeup (P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); } } else { - proj_log_debug (P, "Horner: Must specify polynomial degree, (+deg=n)"); - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + proj_log_error (P, _("Horner: Must specify polynomial degree, (+deg=n)")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } if (pj_param (P->ctx, P->params, "tfwd_c").i || pj_param (P->ctx, P->params, "tinv_c").i) /* complex polynomium? */ @@ -473,7 +473,7 @@ PJ *PROJECTION(horner) { Q = horner_alloc (degree, complex_polynomia); if (Q == nullptr) - return horner_freeup (P, ENOMEM); + return horner_freeup (P, PROJ_ERR_INVALID_OP /*ENOMEM*/); P->opaque = Q; if (complex_polynomia) { @@ -483,9 +483,15 @@ PJ *PROJECTION(horner) { n = 2*degree + 2; if (0==parse_coefs (P, Q->fwd_c, "fwd_c", n)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing fwd_c")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } if (0==parse_coefs (P, Q->inv_c, "inv_c", n)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing inv_c")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } P->fwd4d = complex_horner_forward_4d; P->inv4d = complex_horner_reverse_4d; } @@ -493,19 +499,37 @@ PJ *PROJECTION(horner) { else { n = horner_number_of_coefficients (degree); if (0==parse_coefs (P, Q->fwd_u, "fwd_u", n)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing fwd_u")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } if (0==parse_coefs (P, Q->fwd_v, "fwd_v", n)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing fwd_v")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } if (0==parse_coefs (P, Q->inv_u, "inv_u", n)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing inv_u")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } if (0==parse_coefs (P, Q->inv_v, "inv_v", n)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing inv_v")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } } if (0==parse_coefs (P, (double *)(Q->fwd_origin), "fwd_origin", 2)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing fwd_origin")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } if (0==parse_coefs (P, (double *)(Q->inv_origin), "inv_origin", 2)) - return horner_freeup (P, PJD_ERR_MISSING_ARGS); + { + proj_log_error (P, _("Horner: missing inv_origin")); + return horner_freeup (P, PROJ_ERR_INVALID_OP_MISSING_ARG); + } if (0==parse_coefs (P, &Q->range, "range", 1)) Q->range = 500000; diff --git a/src/transformations/molodensky.cpp b/src/transformations/molodensky.cpp index bf5960d2..4a6584a9 100644 --- a/src/transformations/molodensky.cpp +++ b/src/transformations/molodensky.cpp @@ -245,7 +245,7 @@ static PJ_XYZ forward_3d(PJ_LPZ lpz, PJ *P) { lpz = calc_standard_params(lpz, P); } if( lpz.lam == HUGE_VAL ) { - proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); + proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); return proj_coord_error().xyz; } @@ -277,7 +277,7 @@ static PJ_LPZ reverse_3d(PJ_XYZ xyz, PJ *P) { lpz = calc_standard_params(point.lpz, P); if( lpz.lam == HUGE_VAL ) { - proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); + proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); return proj_coord_error().lpz; } @@ -297,10 +297,9 @@ static PJ_COORD reverse_4d(PJ_COORD obs, PJ *P) { PJ *TRANSFORMATION(molodensky,1) { - int count_required_params = 0; struct pj_opaque_molodensky *Q = static_cast(calloc(1, sizeof(struct pj_opaque_molodensky))); if (nullptr==Q) - return pj_default_destructor(P, ENOMEM); + return pj_default_destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); P->opaque = (void *) Q; P->fwd4d = forward_4d; @@ -314,39 +313,42 @@ PJ *TRANSFORMATION(molodensky,1) { P->right = PJ_IO_UNITS_RADIANS; /* read args */ - if (pj_param(P->ctx, P->params, "tdx").i) { - count_required_params ++; - Q->dx = pj_param(P->ctx, P->params, "ddx").f; + if (!pj_param(P->ctx, P->params, "tdx").i) + { + proj_log_error (P, _("molodensky: missing dx")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } + Q->dx = pj_param(P->ctx, P->params, "ddx").f; - if (pj_param(P->ctx, P->params, "tdy").i) { - count_required_params ++; - Q->dy = pj_param(P->ctx, P->params, "ddy").f; + if (!pj_param(P->ctx, P->params, "tdy").i) + { + proj_log_error (P, _("molodensky: missing dy")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } + Q->dy = pj_param(P->ctx, P->params, "ddy").f; - if (pj_param(P->ctx, P->params, "tdz").i) { - count_required_params ++; - Q->dz = pj_param(P->ctx, P->params, "ddz").f; + if (!pj_param(P->ctx, P->params, "tdz").i) + { + proj_log_error (P, _("molodensky: missing dz")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } + Q->dz = pj_param(P->ctx, P->params, "ddz").f; - if (pj_param(P->ctx, P->params, "tda").i) { - count_required_params ++; - Q->da = pj_param(P->ctx, P->params, "dda").f; + if (!pj_param(P->ctx, P->params, "tda").i) + { + proj_log_error (P, _("molodensky: missing da")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } + Q->da = pj_param(P->ctx, P->params, "dda").f; - if (pj_param(P->ctx, P->params, "tdf").i) { - count_required_params ++; - Q->df = pj_param(P->ctx, P->params, "ddf").f; + if (!pj_param(P->ctx, P->params, "tdf").i) + { + proj_log_error (P, _("molodensky: missing df")); + return pj_default_destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } + Q->df = pj_param(P->ctx, P->params, "ddf").f; Q->abridged = pj_param(P->ctx, P->params, "tabridged").i; - /* We want all parameters (except +abridged) to be set */ - if (count_required_params == 0) - return pj_default_destructor(P, PJD_ERR_NO_ARGS); - - if (count_required_params != 5) - return pj_default_destructor(P, PJD_ERR_MISSING_ARGS); - return P; } diff --git a/src/transformations/tinshift.cpp b/src/transformations/tinshift.cpp index 96e0ea4f..8b73c28c 100644 --- a/src/transformations/tinshift.cpp +++ b/src/transformations/tinshift.cpp @@ -86,14 +86,14 @@ PJ *TRANSFORMATION(tinshift, 1) { const char *filename = pj_param(P->ctx, P->params, "sfile").s; if (!filename) { - proj_log_error(P, "tinshift: +file= should be specified."); - return destructor(P, PJD_ERR_NO_ARGS); + proj_log_error(P, _("tinshift: +file= should be specified.")); + return destructor(P, PROJ_ERR_INVALID_OP_MISSING_ARG); } auto file = NS_PROJ::FileManager::open_resource_file(P->ctx, filename); if (nullptr == file) { - proj_log_error(P, "tinshift: Cannot open %s", filename); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("tinshift: Cannot open %s"), filename); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } file->seek(0, SEEK_END); unsigned long long size = file->tell(); @@ -101,15 +101,15 @@ PJ *TRANSFORMATION(tinshift, 1) { // that could be a denial of service risk. 10 MB should be sufficiently // large for any valid use ! if (size > 10 * 1024 * 1024) { - proj_log_error(P, "tinshift: File %s too large", filename); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("tinshift: File %s too large"), filename); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } file->seek(0); std::string jsonStr; jsonStr.resize(static_cast(size)); if (file->read(&jsonStr[0], jsonStr.size()) != jsonStr.size()) { - proj_log_error(P, "tinshift: Cannot read %s", filename); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("tinshift: Cannot read %s"), filename); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } auto Q = new tinshiftData(); @@ -119,8 +119,8 @@ PJ *TRANSFORMATION(tinshift, 1) { try { Q->evaluator.reset(new Evaluator(TINShiftFile::parse(jsonStr))); } catch (const std::exception &e) { - proj_log_error(P, "tinshift: invalid model: %s", e.what()); - return destructor(P, PJD_ERR_INVALID_ARG); + proj_log_error(P, _("tinshift: invalid model: %s"), e.what()); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } P->destructor = destructor; diff --git a/src/transformations/vgridshift.cpp b/src/transformations/vgridshift.cpp index 3d9f046a..b85e4ba4 100644 --- a/src/transformations/vgridshift.cpp +++ b/src/transformations/vgridshift.cpp @@ -179,8 +179,8 @@ PJ *TRANSFORMATION(vgridshift,0) { P->reassign_context = reassign_context; if (!pj_param(P->ctx, P->params, "tgrids").i) { - proj_log_error(P, "vgridshift: +grids parameter missing."); - return destructor(P, PJD_ERR_NO_ARGS); + proj_log_error(P, _("hgridshift: +grids parameter missing.")); + return destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } /* TODO: Refactor into shared function that can be used */ @@ -227,8 +227,8 @@ PJ *TRANSFORMATION(vgridshift,0) { /* Was gridlist compiled properly? */ if ( proj_errno(P) ) { - proj_log_error(P, "vgridshift: could not find required grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("vgridshift: could not find required grid(s).")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } gMutex.lock(); diff --git a/src/transformations/xyzgridshift.cpp b/src/transformations/xyzgridshift.cpp index e37e874d..d00d6484 100644 --- a/src/transformations/xyzgridshift.cpp +++ b/src/transformations/xyzgridshift.cpp @@ -257,7 +257,7 @@ PJ *TRANSFORMATION(xyzgridshift,0) { // Pass a dummy ellipsoid definition that will be overridden just afterwards Q->cart = proj_create(P->ctx, "+proj=cart +a=1"); if (Q->cart == nullptr) - return destructor(P, ENOMEM); + return destructor(P, PROJ_ERR_INVALID_OP /*ENOMEM*/); /* inherit ellipsoid definition from P to Q->cart */ pj_inherit_ellipsoid_def (P, Q->cart); @@ -272,14 +272,14 @@ PJ *TRANSFORMATION(xyzgridshift,0) { // in RGF93 Q->grid_ref_is_input = false; } else { - proj_log_error(P, "xyzgridshift: unusupported value for grid_ref"); - return destructor (P, PJD_ERR_NO_ARGS); + proj_log_error(P, _("xyzgridshift: unusupported value for grid_ref")); + return destructor(P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE); } } if (0==pj_param(P->ctx, P->params, "tgrids").i) { - proj_log_error(P, "xyzgridshift: +grids parameter missing."); - return destructor (P, PJD_ERR_NO_ARGS); + proj_log_error(P, _("xyzgridshift: +grids parameter missing.")); + return destructor (P, PROJ_ERR_INVALID_OP_MISSING_ARG); } /* multiplier for delta x,y,z */ @@ -294,8 +294,8 @@ PJ *TRANSFORMATION(xyzgridshift,0) { Q->grids = pj_generic_grid_init(P, "grids"); /* Was gridlist compiled properly? */ if ( proj_errno(P) ) { - proj_log_error(P, "xyzgridshift: could not find required grid(s)."); - return destructor(P, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_log_error(P, _("xyzgridshift: could not find required grid(s).")); + return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID); } } -- cgit v1.2.3