MCPcopy Create free account
hub / github.com/MapServer/MapServer / msOWSProcessException

Function msOWSProcessException

mapows.c:1726–1781  ·  view source on GitHub ↗

* msOWSProcessException() * **********************************************************************/

Source from the content-addressed store, hash-verified

1724 *
1725 **********************************************************************/
1726void msOWSProcessException(layerObj *lp, const char *pszFname,
1727 int nErrorCode, const char *pszFuncName)
1728{
1729 FILE *fp;
1730
1731 if ((fp = fopen(pszFname, "r")) != NULL)
1732 {
1733 char *pszBuf=NULL;
1734 int nBufSize=0;
1735 char *pszStart, *pszEnd;
1736
1737 fseek(fp, 0, SEEK_END);
1738 nBufSize = ftell(fp);
1739 rewind(fp);
1740 pszBuf = (char*)malloc((nBufSize+1)*sizeof(char));
1741 if (pszBuf == NULL)
1742 {
1743 msSetError(MS_MEMERR, NULL, "msOWSProcessException()");
1744 fclose(fp);
1745 return;
1746 }
1747
1748 if ((int) fread(pszBuf, 1, nBufSize, fp) != nBufSize)
1749 {
1750 msSetError(MS_IOERR, NULL, "msOWSProcessException()");
1751 free(pszBuf);
1752 fclose(fp);
1753 return;
1754 }
1755
1756 pszBuf[nBufSize] = '\0';
1757
1758
1759 /* OK, got the data in the buffer. Look for the <Message> tags */
1760 if ((strstr(pszBuf, "<WFS_Exception>") && /* WFS style */
1761 (pszStart = strstr(pszBuf, "<Message>")) &&
1762 (pszEnd = strstr(pszStart, "</Message>")) ) ||
1763 (strstr(pszBuf, "<ServiceExceptionReport>") && /* WMS style */
1764 (pszStart = strstr(pszBuf, "<ServiceException>")) &&
1765 (pszEnd = strstr(pszStart, "</ServiceException>")) ))
1766 {
1767 pszStart = strchr(pszStart, '>')+1;
1768 *pszEnd = '\0';
1769 msSetError(nErrorCode, "Got Remote Server Exception for layer %s: %s",
1770 pszFuncName, lp->name?lp->name:"(null)", pszStart);
1771 }
1772 else
1773 {
1774 msSetError(MS_WFSCONNERR, "Unable to parse Remote Server Exception Message for layer %s.",
1775 pszFuncName, lp->name?lp->name:"(null)");
1776 }
1777
1778 free(pszBuf);
1779 fclose(fp);
1780 }
1781}
1782
1783/**********************************************************************

Callers 1

msWFSLayerWhichShapesFunction · 0.85

Calls 1

msSetErrorFunction · 0.85

Tested by

no test coverage detected