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.
18 using Tizen.Internals.Errors;
20 namespace Tizen.Network.Nfc
23 /// Enumeration for the NFC Error.
25 /// <since_tizen> 3 </since_tizen>
31 None = ErrorCode.None,
35 IoError = ErrorCode.IoError,
37 /// Invalid Parameter.
39 InvalidParameterError = ErrorCode.InvalidParameter,
43 OutOfMemoryError = ErrorCode.OutOfMemory,
47 TimedOutError = ErrorCode.TimedOut,
51 DeviceBusyError = ErrorCode.ResourceBusy,
55 NotSupportedError = ErrorCode.NotSupported,
57 /// Permission Denied.
59 PermissionDeniedError = ErrorCode.PermissionDenied,
63 OperationFailedError = -0x01C20000 | 0x01,
65 /// Invalied Ndef Message.
67 InvalidNdefMessageError = -0x01C20000 | 0x02,
69 /// Invalid Record Type.
71 InvalidRecordTypeError = -0x01C20000 | 0x03,
75 NoDeviceError = -0x01C20000 | 0x04,
79 NotActivatedError = -0x01C20000 | 0x05,
81 /// Already Activated.
83 AlreadyActivatedError = -0x01C20000 | 0x06,
85 /// Already Deactivated.
87 AlreadyDeactivatedError = -0x01C20000 | 0x07,
91 ReadOnlyNdefError = -0x01C20000 | 0x08,
95 NoSpaceOnNdefError = -0x01C20000 | 0x09,
99 NoNdefMessageError = -0x01C20000 | 0x0a,
103 NotNdefFormatError = -0x01C20000 | 0x0b,
105 /// Security Restricted
107 SecurityRestrictedError = -0x01C20000 | 0x0c,
111 IllegalStateError = -0x01C20000 | 0x0d,
115 NotInitializedError = -0x01C20000 | 0x0e,
117 /// Tag Not Supported
119 TagNotSupportedError = -0x01C20000 | 0x0f,
121 /// Aid Already Registered
123 AidAlreadyRegisteredError = -0x01C20000 | 0x10
126 internal static class NfcErrorFactory
128 static internal void ThrowNfcException(int e)
130 ThrowException(e, false);
133 static internal void ThrowNfcException(int e, int handle)
135 ThrowException(e, (handle < 0));
138 static private void ThrowException(int e, bool isHandleNull)
140 NfcError err = (NfcError)e;
144 throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
147 if (err == NfcError.InvalidParameterError)
149 throw new ArgumentException(err.ToString());
151 else if (err == NfcError.NotSupportedError)
153 throw new NotSupportedException();
157 throw new InvalidOperationException(err.ToString());