2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 namespace Tizen.Applications.Notifications
20 using System.Runtime.CompilerServices;
22 internal enum NotificationError
24 None = Tizen.Internals.Errors.ErrorCode.None,
25 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
26 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
27 IoError = Tizen.Internals.Errors.ErrorCode.IoError,
28 DbError = -0x01140000 | 0x01,
29 AlreadyExists = -0x01140000 | 0x02,
30 DBusError = -0x01140000 | 0x03,
31 DoesnotExist = -0x01140000 | 0x04,
32 ServiceError = -0x01140000 | 0x05,
33 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
34 InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation
37 internal static class NotificationErrorFactory
39 internal static Exception GetException(NotificationError ret, string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
41 Log.Error(Notification.LogTag, memberName + " : " + lineNumber);
45 case NotificationError.InvalidParameter:
46 Log.Error(Notification.LogTag, msg);
47 return new ArgumentException(ret + " error occurred.");
48 case NotificationError.PermissionDenied:
49 throw new UnauthorizedAccessException("Permission denied (http://tizen.org/privilege/notification)");
51 Log.Error(Notification.LogTag, msg);
52 return new InvalidOperationException(ret + " error occurred.");