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.Mtp
22 static internal class MtpErrorValue
24 internal const int Base = -0x01CC0000;
28 /// Enumeration for Mtp Error.
30 /// <since_tizen> 5 </since_tizen>
33 None = ErrorCode.None,
34 IoError = ErrorCode.IoError,
35 InvalidParameterError = ErrorCode.InvalidParameter,
36 OutOfMemoryError = ErrorCode.OutOfMemory,
37 PermissionDeniedError = ErrorCode.PermissionDenied,
38 NotSupportedError = ErrorCode.NotSupported,
40 CommunicationError = MtpErrorValue.Base | 0x01,
41 ControllerError = MtpErrorValue.Base | 0x02,
42 NoDeviceError = MtpErrorValue.Base | 0x03,
43 NotInitializedError = MtpErrorValue.Base | 0x04,
44 NotActivatedError = MtpErrorValue.Base | 0x05,
45 NotActivatedCommunicationError = MtpErrorValue.Base | 0x06,
46 PluginFailError = MtpErrorValue.Base | 0x07
49 internal static class MtpErrorFactory
51 static internal void ThrowMtpException(int e)
53 ThrowException(e, false);
56 static internal void ThrowMtpException(int e, int handle)
58 ThrowException(e, (handle < 0));
61 static private void ThrowException(int e, bool isHandleNull)
63 MtpError err = (MtpError)e;
67 throw new InvalidOperationException("Invalid instance (object may have been disposed or released)");
70 if (err == MtpError.InvalidParameterError)
72 throw new ArgumentException(err.ToString());
74 else if (err == MtpError.NotSupportedError)
76 throw new NotSupportedException();
80 throw new InvalidOperationException(err.ToString());