2 * Copyright (c) 2018 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.Mtp
22 static internal class MtpErrorValue
24 internal const int Base = -0x01CC0000;
28 /// Enumeration for Mtp Error.
30 /// <since_tizen> 4 </since_tizen>
36 None = ErrorCode.None,
40 IoError = ErrorCode.IoError,
42 /// Invalid Parameter.
44 InvalidParameterError = ErrorCode.InvalidParameter,
48 OutOfMemoryError = ErrorCode.OutOfMemory,
50 /// Permission Denied.
52 PermissionDeniedError = ErrorCode.PermissionDenied,
56 NotSupportedError = ErrorCode.NotSupported,
58 /// Not available communication with Mtp framework.
60 CommunicationError = MtpErrorValue.Base | 0x01,
64 ControllerError = MtpErrorValue.Base | 0x02,
68 NoDeviceError = MtpErrorValue.Base | 0x03,
72 NotInitializedError = MtpErrorValue.Base | 0x04,
76 NotActivatedError = MtpErrorValue.Base | 0x05,
78 /// Not Activated Communication.
80 NotActivatedCommunicationError = MtpErrorValue.Base | 0x06,
84 PluginFailError = MtpErrorValue.Base | 0x07
87 internal static class MtpErrorFactory
89 static internal void ThrowMtpException(int e)
91 ThrowException(e, false);
94 static internal void ThrowMtpException(int e, int handle)
96 ThrowException(e, (handle < 0));
99 static private void ThrowException(int e, bool isHandleNull)
101 MtpError err = (MtpError)e;
105 throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
108 if (err == MtpError.InvalidParameterError)
110 throw new ArgumentException(err.ToString());
112 else if (err == MtpError.NotSupportedError)
114 throw new NotSupportedException();
118 throw new InvalidOperationException(err.ToString());