642 { |
642 { |
643 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
643 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
644 } |
644 } |
645 } |
645 } |
646 } |
646 } |
647 public static void handleCreateCalendarError(int aNativeErrorCode, String aCalName) |
647 |
648 { |
|
649 |
|
650 |
|
651 if (aNativeErrorCode == OsErrorMessage.SUCCESS) |
|
652 { |
|
653 return; // OK |
|
654 } |
|
655 |
|
656 switch (aNativeErrorCode) |
|
657 { |
|
658 case OsErrorMessage.KERR_ARGUMENT: |
|
659 { |
|
660 throw new IllegalArgumentException( |
|
661 "Creation of calendar failed: calendar name is invalid" |
|
662 + aCalName); |
|
663 } |
|
664 case OsErrorMessage.KERR_BAD_NAME: |
|
665 { |
|
666 throw new IllegalArgumentException( |
|
667 "Creation of calendar failed: calendar name is not valid " |
|
668 + aCalName); |
|
669 } |
|
670 case OsErrorMessage.KERR_ALREADY_EXISTS: |
|
671 { |
|
672 throw new RuntimeException(ErrorString.CALENDAR_ALREADY_EXISTS); |
|
673 } |
|
674 default: |
|
675 { |
|
676 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
677 } |
|
678 } |
|
679 } |
|
680 |
|
681 public static void handleDeleteCalendarError(int aNativeErrorCode, String aCalName) |
|
682 { |
|
683 |
|
684 |
|
685 if (aNativeErrorCode == OsErrorMessage.SUCCESS) |
|
686 { |
|
687 return; // OK |
|
688 } |
|
689 |
|
690 switch (aNativeErrorCode) |
|
691 { |
|
692 case OsErrorMessage.KERR_ACCESS_DENIED: |
|
693 { |
|
694 throw new IllegalArgumentException( |
|
695 "Deletion of calendar failed: phone default calendar cannot be deleted"); |
|
696 } |
|
697 case OsErrorMessage.KERR_ARGUMENT: |
|
698 { |
|
699 // we should never end up here since the calendar name is |
|
700 // verified to be not empty before making the native call |
|
701 throw new IllegalArgumentException( |
|
702 "Deletion of calendar failed: calendar name is null"); |
|
703 } |
|
704 case OsErrorMessage.KERR_NOT_FOUND: |
|
705 { |
|
706 throw new IllegalArgumentException( |
|
707 "Deletion of calendar failed: calendar by name " |
|
708 + aCalName + " cannot be found"); |
|
709 } |
|
710 case OsErrorMessage.KERR_BAD_NAME: |
|
711 { |
|
712 throw new IllegalArgumentException( |
|
713 "Deletion of calendar failed: calendar name " |
|
714 + aCalName + " includes a path explicitly"); |
|
715 } |
|
716 default: |
|
717 { |
|
718 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
719 } |
|
720 } |
|
721 } |
|
722 /** |
648 /** |
723 * Construction prohibited. |
649 * Construction prohibited. |
724 */ |
650 */ |
725 private NativeError() |
651 private NativeError() |
726 { |
652 { |