2 using System.Collections.Generic;
5 using System.Threading.Tasks;
6 using Tizen.Internals.Errors;
8 namespace Tizen.Applications.Messages
10 internal enum MessagePortError
12 None = ErrorCode.None,
13 IOError = ErrorCode.IoError,
14 OutOfMemory = ErrorCode.OutOfMemory,
15 InvalidParameter = ErrorCode.InvalidParameter,
16 InvalidOperation = ErrorCode.InvalidOperation,
17 PortNotFound = -0x01130000 | 0x01,
18 CertificateNotMatch = -0x01130000 | 0x02,
19 MaxExceeded = -0x01130000 | 0x03,
20 ResourceUnavailable = -0x01130000 | 0x04
22 internal static class MessagePortErrorFactory
24 internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
26 MessagePortError err = (MessagePortError)errorCode;
27 if (String.IsNullOrEmpty(errorMessage))
29 errorMessage = err.ToString();
31 switch ((MessagePortError)errorCode)
33 case MessagePortError.IOError:
34 case MessagePortError.OutOfMemory:
35 case MessagePortError.InvalidOperation:
36 case MessagePortError.PortNotFound:
37 case MessagePortError.ResourceUnavailable: throw new InvalidOperationException(errorMessage);
38 case MessagePortError.InvalidParameter:
39 case MessagePortError.CertificateNotMatch: throw new ArgumentException(errorMessage, paramName);
40 case MessagePortError.MaxExceeded: throw new ArgumentOutOfRangeException(paramName, errorMessage);