aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2019-04-02 13:30:33 +0200
committerKristian Evers <kristianevers@gmail.com>2019-04-02 20:58:35 +0200
commit20300c1fd5b35bf1d577a3726f02940d02c73f54 (patch)
tree0706b4f3102bf1ba1f459b50d0ea0ad875d84c24 /src
parent2a0ad3d42c7342ee060791aba01f70f058238dce (diff)
downloadPROJ-20300c1fd5b35bf1d577a3726f02940d02c73f54.tar.gz
PROJ-20300c1fd5b35bf1d577a3726f02940d02c73f54.zip
Make sure that ISO19111 C++ code sets pj_errno on errors
Diffstat (limited to 'src')
-rw-r--r--src/apps/gie.cpp1
-rw-r--r--src/iso19111/c_api.cpp5
-rw-r--r--src/proj_internal.h1
-rw-r--r--src/strerrno.cpp1
4 files changed, 8 insertions, 0 deletions
diff --git a/src/apps/gie.cpp b/src/apps/gie.cpp
index 47211aa8..912113b4 100644
--- a/src/apps/gie.cpp
+++ b/src/apps/gie.cpp
@@ -1151,6 +1151,7 @@ static const struct errno_vs_err_const lookup[] = {
{"pjd_err_invalid_arg" , -58},
{"pjd_err_inconsistent_unit" , -59},
{"pjd_err_mutually_exclusive_args" , -60},
+ {"pjd_err_generic_error" , -61},
{"pjd_err_dont_skip" , 5555},
{"pjd_err_unknown" , 9999},
{"pjd_err_enomem" , ENOMEM},
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp
index b15b8e34..970d38d8 100644
--- a/src/iso19111/c_api.cpp
+++ b/src/iso19111/c_api.cpp
@@ -77,6 +77,11 @@ static void PROJ_NO_INLINE proj_log_error(PJ_CONTEXT *ctx, const char *function,
msg += ": ";
msg += text;
ctx->logger(ctx->logger_app_data, PJ_LOG_ERROR, msg.c_str());
+ auto previous_errno = pj_ctx_get_errno(ctx);
+ if (previous_errno == 0) {
+ // only set errno if it wasn't set deeper down the call stack
+ pj_ctx_set_errno(ctx, PJD_ERR_GENERIC_ERROR);
+ }
}
// ---------------------------------------------------------------------------
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 880e194f..507bd329 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -679,6 +679,7 @@ struct FACTORS {
#define PJD_ERR_INVALID_ARG -58
#define PJD_ERR_INCONSISTENT_UNIT -59
#define PJD_ERR_MUTUALLY_EXCLUSIVE_ARGS -60
+#define PJD_ERR_GENERIC_ERROR -61
/* NOTE: Remember to update src/strerrno.cpp, src/apps/gie.cpp and transient_error in */
/* src/transform.cpp when adding new value */
diff --git a/src/strerrno.cpp b/src/strerrno.cpp
index af130fc4..4020cb23 100644
--- a/src/strerrno.cpp
+++ b/src/strerrno.cpp
@@ -70,6 +70,7 @@ pj_err_list[] = {
"argument not numerical or out of range", /* -58 */
"inconsistent unit type between input and output", /* -59 */
"arguments are mutually exclusive", /* -60 */
+ "generic error of unknow origin", /* -61 */
/* When adding error messages, remember to update ID defines in
projects.h, and transient_error array in pj_transform */