Debian Codegraph @

core/java/android/webkit/LegacyErrorStrings.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 package android.webkit;
18
19 import android.content.Context;
20 import android.util.Log;
21
22 /**
23 * Localized strings for the error codes defined in EventHandler.
24 *
25 * {@hide}
26 */
27 class LegacyErrorStrings {
28 private LegacyErrorStrings() { /* Utility class, don't instantiate. */ }
29
30 private static final String LOGTAG = "Http";
31
32 /**
33 * Get the localized error message resource for the given error code.
34 * If the code is unknown, we'll return a generic error message.
35 */
36 static String getString(int errorCode, Context context) {
37 return context.getText(getResource(errorCode)).toString();
38 }
39
40 /**
41 * Get the localized error message resource for the given error code.
42 * If the code is unknown, we'll return a generic error message.
43 */
44 private static int getResource(int errorCode) {
45 switch(errorCode) {
46 case 0: /* EventHandler.OK: */
47 return com.android.internal.R.string.httpErrorOk;
48
49 case -1: /* EventHandler.ERROR: */
50 return com.android.internal.R.string.httpError;
51
52 case -2: /* EventHandler.ERROR_LOOKUP: */
53 return com.android.internal.R.string.httpErrorLookup;
54
55 case -3: /* EventHandler.ERROR_UNSUPPORTED_AUTH_SCHEME: */
56 return com.android.internal.R.string.httpErrorUnsupportedAuthScheme;
57
58 case -4: /* EventHandler.ERROR_AUTH: */
59 return com.android.internal.R.string.httpErrorAuth;
60
61 case -5: /* EventHandler.ERROR_PROXYAUTH: */
62 return com.android.internal.R.string.httpErrorProxyAuth;
63
64 case -6: /* EventHandler.ERROR_CONNECT: */
65 return com.android.internal.R.string.httpErrorConnect;
66
67 case -7: /* EventHandler.ERROR_IO: */
68 return com.android.internal.R.string.httpErrorIO;
69
70 case -8: /* EventHandler.ERROR_TIMEOUT: */
71 return com.android.internal.R.string.httpErrorTimeout;
72
73 case -9: /* EventHandler.ERROR_REDIRECT_LOOP: */
74 return com.android.internal.R.string.httpErrorRedirectLoop;
75
76 case -10: /* EventHandler.ERROR_UNSUPPORTED_SCHEME: */
77 return com.android.internal.R.string.httpErrorUnsupportedScheme;
78
79 case -11: /* EventHandler.ERROR_FAILED_SSL_HANDSHAKE: */
80 return com.android.internal.R.string.httpErrorFailedSslHandshake;
81
82 case -12: /* EventHandler.ERROR_BAD_URL: */
83 return com.android.internal.R.string.httpErrorBadUrl;
84
85 case -13: /* EventHandler.FILE_ERROR: */
86 return com.android.internal.R.string.httpErrorFile;
87
88 case -14: /* EventHandler.FILE_NOT_FOUND_ERROR: */
89 return com.android.internal.R.string.httpErrorFileNotFound;
90
91 case -15: /* EventHandler.TOO_MANY_REQUESTS_ERROR: */
92 return com.android.internal.R.string.httpErrorTooManyRequests;
93
94 default:
95 Log.w(LOGTAG, "Using generic message for unknown error code: " + errorCode);
96 return com.android.internal.R.string.httpError;
97 }
98 }
99 }