aboutsummaryrefslogtreecommitdiff
path: root/src/transformations/defmodel.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-12-15 00:51:46 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-12-15 01:13:43 +0100
commit244a24104ded3a4573aeffa32160af21f76cbce6 (patch)
treef3a11529172719657cf7576e062e45e0f9452db5 /src/transformations/defmodel.cpp
parent1e9894b0e2b161e61546672bccb85a9ef21df541 (diff)
downloadPROJ-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/transformations/defmodel.cpp')
-rw-r--r--src/transformations/defmodel.cpp22
1 files changed, 11 insertions, 11 deletions
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_t>(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<Grid, GridSet, EvaluatorIface>(
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;