<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Laurențiu,</p>
<blockquote type="cite"
cite="mid:40f159cf-aa88-432d-9235-df17b35a55a6@betaapp.fastmail.com">
<div style="font-family:Arial;">Many GDAL functions can return
nullptr (e.g. OSRGetName, OSRGetAuthorityCode etc.), but it's
not clear if they set an error message that can be retrieved
using CPLGetLastErrorMsg. I tried to check the code, but
CPLErrorSetState isn't called from many places, so I'm probably
missing something like a PROJ/GEOS error handler that sets it.<br>
</div>
</blockquote>
<p>- OSRGetName() would return null only if the SRS is invalid/unset
(you won't get any CPLError() in that situation). If a unlikely
memory allocation error would occur in PROJ, I believe, but I'm
not completely sure, that PROJ would emit a PROJ error that would
be transformed as a GDAL CE_Failure through the osr_proj_logger()
PROJ-error handler installed in ogr/ogr_proj_p.cpp.</p>
<p>- similarly for OSRGetAuthorityCode(). Returns null on
invalid/unset SRS or SRS without identifier, without emitting a
CPLError(). And same as above if the error occurs within PROJ<br>
</p>
<blockquote type="cite"
cite="mid:40f159cf-aa88-432d-9235-df17b35a55a6@betaapp.fastmail.com">
<div style="font-family:Arial;"><br>
</div>
<div style="font-family:Arial;">Is there any rule-of-thumb for
figuring out when CPLGetLastErrorMsg should be used?<br>
</div>
</blockquote>
<p>No. If you are paranoid about that, reset the error state with
CPLErrorReset() before calling a function and check
CPLGetLastErrorType() == CE_Failure after, but probably only if
the return code of the function is an error. In some
circumstances, a function might return a valid output, but a
CE_Failure can be emitted by deep layers of GDAL but recovered by
upper layers that will miss resetting the error state.</p>
Even
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.
Butcher of all kinds of standards, open or closed formats. At the end, this is just about bytes.</pre>
</body>
</html>