javaextensions/pim/javasrc.s60/com/nokia/mj/impl/pim/utils/NativeError.java
changeset 76 4ad59aaee882
parent 21 2a9601315dfc
child 72 1f0034e370aa
child 83 26b2b12093af
--- a/javaextensions/pim/javasrc.s60/com/nokia/mj/impl/pim/utils/NativeError.java	Thu Sep 02 20:20:40 2010 +0300
+++ b/javaextensions/pim/javasrc.s60/com/nokia/mj/impl/pim/utils/NativeError.java	Fri Sep 17 08:28:21 2010 +0300
@@ -644,7 +644,81 @@
         }
         }
     }
+    public static void handleCreateCalendarError(int aNativeErrorCode, String aCalName)
+    {
 
+
+        if (aNativeErrorCode == OsErrorMessage.SUCCESS)
+        {
+            return; // OK
+        }
+
+        switch (aNativeErrorCode)
+        {
+        case OsErrorMessage.KERR_ARGUMENT:
+        {
+            throw new IllegalArgumentException(
+                "Creation of calendar failed: calendar name is invalid"
+                + aCalName);
+        }
+        case OsErrorMessage.KERR_BAD_NAME:
+        {
+            throw new IllegalArgumentException(
+                "Creation of calendar failed: calendar name is not valid "
+                + aCalName);
+        }
+        case OsErrorMessage.KERR_ALREADY_EXISTS:
+        {
+            throw new RuntimeException(ErrorString.CALENDAR_ALREADY_EXISTS);
+        }
+        default:
+        {
+            throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode);
+        }
+        }
+    }
+
+    public static void handleDeleteCalendarError(int aNativeErrorCode, String aCalName)
+    {
+
+
+        if (aNativeErrorCode == OsErrorMessage.SUCCESS)
+        {
+            return; // OK
+        }
+
+        switch (aNativeErrorCode)
+        {
+        case OsErrorMessage.KERR_ACCESS_DENIED:
+        {
+            throw new IllegalArgumentException(
+                "Deletion of calendar failed: phone default calendar cannot be deleted");
+        }
+        case OsErrorMessage.KERR_ARGUMENT:
+        {
+            // we should never end up here since the calendar name is
+            // verified to be not empty before making   the native call
+            throw new IllegalArgumentException(
+                "Deletion of calendar failed: calendar name is null");
+        }
+        case OsErrorMessage.KERR_NOT_FOUND:
+        {
+            throw new IllegalArgumentException(
+                "Deletion of calendar failed: calendar by name "
+                + aCalName + " cannot be found");
+        }
+        case OsErrorMessage.KERR_BAD_NAME:
+        {
+            throw new IllegalArgumentException(
+                "Deletion of calendar failed: calendar name "
+                + aCalName + " includes a path explicitly");
+        }
+        default:
+        {
+            throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode);
+        }
+        }
+    }
     /**
      * Construction prohibited.
      */