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.Smartcard
22 internal enum SmartcardError
24 None = ErrorCode.None,
25 IoError = ErrorCode.IoError,
26 InvalidParameterError = ErrorCode.InvalidParameter,
27 PermissionDeniedError = ErrorCode.PermissionDenied,
28 NotSupportedError = ErrorCode.NotSupported,
29 GeneralError = -0x01C70000 | 0x01,
30 NoSuchElementError = -0x01C70000 | 0x02,
31 IllegalStateError = -0x01C70000 | 0x03,
32 IllegalReferenceError = -0x01C70000 | 0x04,
33 OperationNotSupportError = -0x01C70000 | 0x05,
34 ChannelNotAvailableError = -0x01C70000 | 0x06,
35 NotInitializedError = -0x01C70000 | 0x07
38 internal static class SmartcardErrorFactory
40 static internal void ThrowSmartcardException(int e)
42 ThrowException(e, false);
45 static internal void ThrowSmartcardException(int e, int handle)
47 ThrowException(e, (handle < 0));
50 static private void ThrowException(int e, bool isHandleNull)
52 SmartcardError err = (SmartcardError)e;
56 throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
59 if (err == SmartcardError.InvalidParameterError)
61 throw new ArgumentException(err.ToString());
63 else if (err == SmartcardError.NotSupportedError)
65 throw new NotSupportedException(err.ToString());
69 throw new InvalidOperationException(err.ToString());