2 * Copyright (c) 2017 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
20 using System.Runtime.CompilerServices;
22 internal enum BadgeError
24 None = Tizen.Internals.Errors.ErrorCode.None,
25 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
26 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
27 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
28 IoError = Tizen.Internals.Errors.ErrorCode.IoError,
29 DbError = -0x01120000 | 0x01,
30 AlreadyExists = -0x01120000 | 0x02,
31 DBusError = -0x01120000 | 0x03,
32 DoesnotExist = -0x01120000 | 0x04,
33 ServiceError = -0x01120000 | 0x05,
34 InvalidPackage = -0x01120000 | 0x06
38 /// Immutable class for getting the badge information.
40 internal static class BadgeErrorFactory
42 private static readonly string LogTag = "Tizen.Applications.Badge";
44 internal static Exception GetException(BadgeError ret, string msg, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0)
46 Log.Error(LogTag, memberName + " : " + lineNumber);
50 case BadgeError.InvalidParameter:
51 Log.Error(LogTag, msg);
52 return new ArgumentException(ret + " error occurred.");
53 case BadgeError.PermissionDenied:
54 throw new UnauthorizedAccessException("Permission denied (http://tizen.org/privilege/notification)");
56 Log.Error(LogTag, msg);
57 return new InvalidOperationException(ret + " error occurred.");