Author: hansbak
Date: Sun Apr 15 07:58:09 2012
New Revision: 1326268
URL:
http://svn.apache.org/viewvc?rev=1326268&view=revLog:
improve error messages by replacing null pointer exception with meaningfull message
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java?rev=1326268&r1=1326267&r2=1326268&view=diff==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java Sun Apr 15 07:58:09 2012
@@ -326,12 +326,23 @@ public class CmsEvents {
}
}
String siteName = null;
+ GenericValue webSite = null;
try {
- siteName = delegator.findByPrimaryKeyCache("WebSite", UtilMisc.toMap("webSiteId", webSiteId)).getString("siteName");
+ webSite = delegator.findByPrimaryKeyCache("WebSite", UtilMisc.toMap("webSiteId", webSiteId));
+ if (webSite != null) {
+ siteName = webSite.getString("siteName");
+ }
+ if (siteName == null) {
+ siteName = "Not specified";
+ }
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
- request.setAttribute("_ERROR_MESSAGE_", "Not able to find a page to display for website: " + siteName + " [" + webSiteId + "] not even a default page!");
+ if (webSite != null) {
+ request.setAttribute("_ERROR_MESSAGE_", "Not able to find a page to display for website: " + siteName + " [" + webSiteId + "] not even a default page!");
+ } else {
+ request.setAttribute("_ERROR_MESSAGE_", "Not able to find a page to display, not even a default page AND the website entity record for WebSiteId:" + webSiteId + " could not be found");
+ }
return "error";
}