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>
28 None = ErrorCode.None,
29 IoError = ErrorCode.IoError,
30 InvalidParameterError = ErrorCode.InvalidParameter,
31 OutOfMemoryError = ErrorCode.OutOfMemory,
32 TimedOutError = ErrorCode.TimedOut,
33 DeviceBusyError = ErrorCode.ResourceBusy,
34 NotSupportedError = ErrorCode.NotSupported,
35 PermissionDeniedError = ErrorCode.PermissionDenied,
36 OperationFailedError = -0x01C20000 | 0x01,
37 InvalidNdefMessageError = -0x01C20000 | 0x02,
38 InvalidRecordTypeError = -0x01C20000 | 0x03,
39 NoDeviceError = -0x01C20000 | 0x04,
40 NotActivatedError = -0x01C20000 | 0x05,
41 AlreadyActivatedError = -0x01C20000 | 0x06,
42 AlreadyDeactivatedError = -0x01C20000 | 0x07,
43 ReadOnlyNdefError = -0x01C20000 | 0x08,
44 NoSpaceOnNdefError = -0x01C20000 | 0x09,
45 NoNdefMessageError = -0x01C20000 | 0x0a,
46 NotNdefFormatError = -0x01C20000 | 0x0b,
47 SecurityRestrictedError = -0x01C20000 | 0x0c,
48 IllegalStateError = -0x01C20000 | 0x0d,
49 NotInitializedError = -0x01C20000 | 0x0e,
50 TagNotSupportedError = -0x01C20000 | 0x0f,
51 AidAlreadyRegisteredError = -0x01C20000 | 0x10
54 internal static class NfcErrorFactory
56 static internal void ThrowNfcException(int e)
58 ThrowException(e, false);
61 static internal void ThrowNfcException(int e, int handle)
63 ThrowException(e, (handle < 0));
66 static private void ThrowException(int e, bool isHandleNull)
68 NfcError err = (NfcError)e;
72 throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
75 if (err == NfcError.InvalidParameterError)
77 throw new ArgumentException(err.ToString());
79 else if (err == NfcError.NotSupportedError)
81 throw new NotSupportedException();
85 throw new InvalidOperationException(err.ToString());