diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2022-02-04 17:06:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-04 17:06:55 +0100 |
| commit | 0139d8c59f7ed135b03855f549d44a3801c42aa1 (patch) | |
| tree | f44f58395e76d65bc05bf5c0fbdf9df7cb4cd03c | |
| parent | 9033708633f085d7519489e84e5687326bc81432 (diff) | |
| parent | c868ea010de15b98ee1e67a81e0a29cc4a1ab734 (diff) | |
| download | PROJ-0139d8c59f7ed135b03855f549d44a3801c42aa1.tar.gz PROJ-0139d8c59f7ed135b03855f549d44a3801c42aa1.zip | |
Merge pull request #3037 from direvus/2529-err-code-unknown-format
Set more precise error code for parsing errors in proj_create().
| -rw-r--r-- | src/iso19111/c_api.cpp | 5 | ||||
| -rw-r--r-- | test/gie/4D-API_cs2cs-style.gie | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 527ccd4f..4823213b 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -572,6 +572,11 @@ PJ *proj_create(PJ_CONTEXT *ctx, const char *text) { if (identifiedObject) { return pj_obj_create(ctx, NN_NO_CHECK(identifiedObject)); } + } catch (const io::ParsingException &e) { + if (proj_context_errno(ctx) == 0) { + proj_context_errno_set(ctx, PROJ_ERR_INVALID_OP_WRONG_SYNTAX); + } + proj_log_error(ctx, __FUNCTION__, e.what()); } catch (const std::exception &e) { proj_log_error(ctx, __FUNCTION__, e.what()); } diff --git a/test/gie/4D-API_cs2cs-style.gie b/test/gie/4D-API_cs2cs-style.gie index 9189b328..1b0c1541 100644 --- a/test/gie/4D-API_cs2cs-style.gie +++ b/test/gie/4D-API_cs2cs-style.gie @@ -533,11 +533,11 @@ expect 0 0 1 roundtrip 1 ------------------------------------------------------------------------------- -# Check that proj_create() returns a generic error when an exception is caught +# Check that proj_create() returns a syntax error when an exception is caught # in the creation of a PJ object. ------------------------------------------------------------------------------- -operation this is a bogus CRS meant to trigger a generic error in proj_create() -expect failure errno other +operation this is a bogus CRS meant to trigger a syntax error in proj_create() +expect failure errno invalid_op_wrong_syntax ------------------------------------------------------------------------------- # Test proj=set |
