MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLErrorSetState

Function CPLErrorSetState

port/cpl_error.cpp:841–880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839 **********************************************************************/
840
841void CPLErrorSetState(CPLErr eErrClass, CPLErrorNum err_no, const char *pszMsg,
842 const GUInt32 *pnErrorCounter)
843{
844 CPLErrorContext *psCtx = CPLGetErrorContext();
845 if (psCtx == nullptr)
846 return;
847 if (IS_PREFEFINED_ERROR_CTX(psCtx))
848 {
849 int bMemoryError = FALSE;
850 if (eErrClass == CE_None)
851 CPLSetTLSWithFreeFuncEx(
852 CTLS_ERRORCONTEXT,
853 reinterpret_cast<void *>(
854 const_cast<CPLErrorContext *>(&sNoErrorContext)),
855 nullptr, &bMemoryError);
856 else if (eErrClass == CE_Warning)
857 CPLSetTLSWithFreeFuncEx(
858 CTLS_ERRORCONTEXT,
859 reinterpret_cast<void *>(
860 const_cast<CPLErrorContext *>(&sWarningContext)),
861 nullptr, &bMemoryError);
862 else if (eErrClass == CE_Failure)
863 CPLSetTLSWithFreeFuncEx(
864 CTLS_ERRORCONTEXT,
865 reinterpret_cast<void *>(
866 const_cast<CPLErrorContext *>(&sFailureContext)),
867 nullptr, &bMemoryError);
868 return;
869 }
870
871 psCtx->nLastErrNo = err_no;
872 const size_t size = std::min(static_cast<size_t>(psCtx->nLastErrMsgMax - 1),
873 strlen(pszMsg));
874 char *pszLastErrMsg = CPLErrorContextGetString(psCtx);
875 memcpy(pszLastErrMsg, pszMsg, size);
876 pszLastErrMsg[size] = '\0';
877 psCtx->eLastErrType = eErrClass;
878 if (pnErrorCounter)
879 psCtx->nErrorCounter = *pnErrorCounter;
880}
881
882/**
883 * Restore an error state, without emitting an error.

Callers 15

ICreateLayerMethod · 0.85
LoadMethod · 0.85
TEST_FFunction · 0.85
RunStepMethod · 0.85
RunStepMethod · 0.85
LoadJP2MetadataMethod · 0.85
LoadVectorLayersMethod · 0.85
CPLParseXMLStringFunction · 0.85
OpenMethod · 0.85
CreateCopyMethod · 0.85

Calls 4

CPLGetErrorContextFunction · 0.85
CPLSetTLSWithFreeFuncExFunction · 0.85
CPLErrorContextGetStringFunction · 0.85
minFunction · 0.50

Tested by 1

TEST_FFunction · 0.68