|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Native error codes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // PACKAGE |
|
20 package com.nokia.mj.impl.pim.utils; |
|
21 |
|
22 // IMPORTS |
|
23 import javax.microedition.pim.FieldEmptyException; |
|
24 import javax.microedition.pim.FieldFullException; |
|
25 import javax.microedition.pim.PIMException; |
|
26 import javax.microedition.pim.UnsupportedFieldException; |
|
27 import com.nokia.mj.impl.pim.ErrorString; |
|
28 import com.nokia.mj.impl.pim.GenericException; |
|
29 import com.nokia.mj.impl.utils.OsErrorMessage; |
|
30 |
|
31 // CLASS DEFINITION |
|
32 /** |
|
33 * Native side error codes and common error handling operations. In general, the |
|
34 * native side error codes are interpreted to Java exceptions in failing native |
|
35 * side invocations. There are groups of functionality that share common |
|
36 * interpretation for a set of error codes; for these a common error handling |
|
37 * operation is provided. |
|
38 * |
|
39 * The class must be public so that in can be accessed from the |
|
40 * javax.microedition.pim package (classes PIM and RepeatRule). |
|
41 */ |
|
42 public final class NativeError |
|
43 { |
|
44 |
|
45 // @{ |
|
46 /** |
|
47 * Checks given native-originating error code for field handling operations |
|
48 * and in error throws a suitable exception for that error. |
|
49 * |
|
50 * The field handling operations are present mainly in PIMItemImpl and |
|
51 * PIMListImpl classes (data accessors, support checkers, label getters). |
|
52 * |
|
53 * The native error codes and corresponding exceptions are listed below. |
|
54 * |
|
55 * @param aNativeErrorCode |
|
56 * The native error code to check. For error codes other than |
|
57 * OsErrorMessage.SUCCESS an exception is thrown. |
|
58 * |
|
59 * @param aField |
|
60 * The field to mention in the exception description where |
|
61 * applicable. |
|
62 * |
|
63 * @param aIndex |
|
64 * The index to mention in the exception description where |
|
65 * applicable. |
|
66 * |
|
67 * @exception IllegalArgumentException |
|
68 * for OsErrorMessage.KERR_ARGUMENT (invalid field) and |
|
69 * OsErrorMessage.KERR_TOO_BIG (invalid value). |
|
70 * |
|
71 * @exception IndexOutOfBoundsException |
|
72 * for OsErrorMessage.KERR_NOT_FOUND. |
|
73 * |
|
74 * @exception UnsupportedFieldException |
|
75 * for OsErrorMessage.KERR_NOT_SUPPORTED. |
|
76 * |
|
77 * @exception Generic Exception with code |
|
78 * for any other error. |
|
79 */ |
|
80 public static void handleFieldHandlingError(int aNativeErrorCode, int aField, |
|
81 int aIndex) |
|
82 { |
|
83 if (aNativeErrorCode == OsErrorMessage.SUCCESS) |
|
84 { |
|
85 return; // OK |
|
86 } |
|
87 |
|
88 switch (aNativeErrorCode) |
|
89 { |
|
90 case OsErrorMessage.KERR_ARGUMENT: |
|
91 { |
|
92 throw new IllegalArgumentException(ErrorString.INVALID_FIELD_COLON |
|
93 + aField); |
|
94 } |
|
95 case OsErrorMessage.KERR_NOT_SUPPORTED: |
|
96 { |
|
97 throw new UnsupportedFieldException(ErrorString.UNSUPPORTED_FIELD_COLON |
|
98 + aField, aField); |
|
99 } |
|
100 case OsErrorMessage.KERR_NOT_FOUND: |
|
101 { |
|
102 throw new IndexOutOfBoundsException(ErrorString.INVALID_INDEX_COLON + aIndex); |
|
103 } |
|
104 case OsErrorMessage.KERR_TOO_BIG: |
|
105 { |
|
106 throw new IllegalArgumentException(ErrorString.INVALID_VALUE); |
|
107 } |
|
108 case OsErrorMessage.KERR_OVERFLOW: |
|
109 { |
|
110 throw new FieldFullException(ErrorString.FIELD_IS_FULL); |
|
111 } |
|
112 case OsErrorMessage.KERR_LOCKED: |
|
113 { |
|
114 throw new IllegalArgumentException(ErrorString.FIELD_IS_READ_ONLY); |
|
115 } |
|
116 case OsErrorMessage.KERR_NO_MEMORY: |
|
117 { |
|
118 throw new OutOfMemoryError(); |
|
119 } |
|
120 default: |
|
121 { |
|
122 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 public static void handleFieldHandlingError(int aNativeErrorCode, int aField) |
|
128 { |
|
129 handleFieldHandlingError(aNativeErrorCode, aField, 0); |
|
130 } |
|
131 |
|
132 // @} |
|
133 |
|
134 // @{ |
|
135 /** |
|
136 * Checks given native-originating error code for category handling |
|
137 * operations and in error throws a suitable exception for that error. |
|
138 * |
|
139 * The category handling operations are present mainly in PIMListImpl and |
|
140 * PIMItemImpl classes. |
|
141 * |
|
142 * The native error codes and corresponding exceptions are listed below. |
|
143 * |
|
144 * @param aNativeErrorCode |
|
145 * The native error code to check. For error codes other than |
|
146 * OsErrorMessage.SUCCESS an exception is thrown. |
|
147 * |
|
148 * @param aCategory |
|
149 * The category to mention in the exception description where |
|
150 * applicable. |
|
151 * |
|
152 * @exception PIMException |
|
153 * for OsErrorMessage.KERR_SESSION_CLOSED, |
|
154 * OsErrorMessage.KERR_ARGUMENT, |
|
155 * OsErrorMessage.KERR_NOT_SUPPORTED, |
|
156 * OsErrorMessage.KERR_NOT_FOUND and for any other errors by |
|
157 * default. |
|
158 */ |
|
159 public static void handleCategoryHandlingError(int aNativeErrorCode, |
|
160 String aCategory) throws PIMException |
|
161 { |
|
162 if (aNativeErrorCode == OsErrorMessage.SUCCESS) |
|
163 { |
|
164 return; // OK |
|
165 } |
|
166 |
|
167 switch (aNativeErrorCode) |
|
168 { |
|
169 case OsErrorMessage.KERR_SESSION_CLOSED: |
|
170 { |
|
171 throw new PIMException(ErrorString.LIST_IS_CLOSED, PIMException.LIST_CLOSED); |
|
172 } |
|
173 case OsErrorMessage.KERR_ARGUMENT: |
|
174 { |
|
175 String msg = null; |
|
176 if (aCategory != null) |
|
177 { |
|
178 msg = ErrorString.INVALID_CATEGORY_COLON + aCategory; |
|
179 } |
|
180 else |
|
181 { |
|
182 msg = ErrorString.INVALID_CATEGORY; |
|
183 } |
|
184 throw new PIMException(msg, PIMException.GENERAL_ERROR); |
|
185 } |
|
186 case OsErrorMessage.KERR_NOT_FOUND: |
|
187 { |
|
188 throw new PIMException(ErrorString.NO_SUCH_CATEGORY_COLON + aCategory, |
|
189 PIMException.GENERAL_ERROR); |
|
190 } |
|
191 case OsErrorMessage.KERR_NOT_SUPPORTED: |
|
192 { |
|
193 throw new PIMException(ErrorString.CATEGORIES_ARE_NOT_SUPPORTED, |
|
194 PIMException.FEATURE_NOT_SUPPORTED); |
|
195 } |
|
196 case OsErrorMessage.KERR_NO_MEMORY: |
|
197 { |
|
198 throw new OutOfMemoryError(); |
|
199 } |
|
200 default: |
|
201 { |
|
202 throw new PIMException(ErrorString.GENERAL_ERROR, |
|
203 PIMException.GENERAL_ERROR); |
|
204 } |
|
205 } |
|
206 } |
|
207 |
|
208 public static void handleCategoryHandlingError(int aNativeErrorCode) |
|
209 throws PIMException |
|
210 { |
|
211 handleCategoryHandlingError(aNativeErrorCode, null); |
|
212 } |
|
213 |
|
214 |
|
215 |
|
216 public static void handleSerializationError(int aNativeErrorCode) |
|
217 throws PIMException |
|
218 { |
|
219 if (aNativeErrorCode == OsErrorMessage.SUCCESS) |
|
220 { |
|
221 return; // OK |
|
222 } |
|
223 |
|
224 switch (aNativeErrorCode) |
|
225 { |
|
226 case OsErrorMessage.KERR_NOT_FOUND: |
|
227 case OsErrorMessage.KERR_CORRUPT: |
|
228 case OsErrorMessage.KERR_TOO_BIG: |
|
229 case OsErrorMessage.KERR_NOT_SUPPORTED: |
|
230 case OsErrorMessage.KERR_EOF: |
|
231 { |
|
232 throw new PIMException(ErrorString.DATA_SERIALIZATION_FAILED, |
|
233 PIMException.GENERAL_ERROR); |
|
234 } |
|
235 case OsErrorMessage.KERR_NO_MEMORY: |
|
236 { |
|
237 throw new OutOfMemoryError(); |
|
238 } |
|
239 default: |
|
240 { |
|
241 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
242 } |
|
243 } |
|
244 } |
|
245 |
|
246 public static boolean checkSuccess(int aNativeErrorCode) |
|
247 { |
|
248 if (aNativeErrorCode == OsErrorMessage.SUCCESS) |
|
249 { |
|
250 return true; |
|
251 } |
|
252 return false; |
|
253 } |
|
254 |
|
255 public static boolean checkArgumentError(int aNativeErrorCode) |
|
256 { |
|
257 if (aNativeErrorCode == OsErrorMessage.KERR_ARGUMENT) |
|
258 { |
|
259 return true; |
|
260 } |
|
261 return false; |
|
262 } |
|
263 |
|
264 public static void handleRepeatRuleFieldsError(int aNativeErrorCode, int aFrequency) |
|
265 { |
|
266 switch (aNativeErrorCode) |
|
267 { |
|
268 case OsErrorMessage.SUCCESS: |
|
269 { |
|
270 return; // OK |
|
271 } |
|
272 case OsErrorMessage.KERR_ARGUMENT: |
|
273 { |
|
274 // We should never end up here because the argument is prechecked |
|
275 throw new IllegalArgumentException(ErrorString.INVALID_REPEATRULE_VALUE_COLON |
|
276 + aFrequency); |
|
277 } |
|
278 case OsErrorMessage.KERR_NO_MEMORY: |
|
279 { |
|
280 throw new OutOfMemoryError(); |
|
281 } |
|
282 default: |
|
283 { |
|
284 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
285 } |
|
286 } |
|
287 } |
|
288 |
|
289 public static void handleItemCommitError(int aNativeErrorCode) throws PIMException |
|
290 { |
|
291 switch (aNativeErrorCode) |
|
292 { |
|
293 case OsErrorMessage.SUCCESS: |
|
294 { |
|
295 return; // OK |
|
296 } |
|
297 case OsErrorMessage.KERR_ABORT: |
|
298 { |
|
299 throw new PIMException(ErrorString.COMMIT_OPERATION_FAILED_COLON + |
|
300 ErrorString.ITEM_HAS_INSUFFICIENT_DATA, |
|
301 PIMException.GENERAL_ERROR); |
|
302 } |
|
303 case OsErrorMessage.KERR_NOT_FOUND: |
|
304 { |
|
305 throw new PIMException(ErrorString.COMMIT_OPERATION_FAILED_COLON + |
|
306 ErrorString.ITEM_IS_REMOVED, |
|
307 PIMException.GENERAL_ERROR); |
|
308 } |
|
309 case OsErrorMessage.KERR_IN_USE: |
|
310 { |
|
311 throw new PIMException(ErrorString.COMMIT_OPERATION_FAILED_COLON + |
|
312 ErrorString.ITEM_IN_USE, |
|
313 PIMException.UPDATE_ERROR); |
|
314 } |
|
315 case OsErrorMessage.KERR_DISCONNECTED: |
|
316 { |
|
317 throw new PIMException(ErrorString.COMMIT_OPERATION_FAILED_COLON + |
|
318 ErrorString.LIST_IS_CLOSED, |
|
319 PIMException.LIST_CLOSED); |
|
320 } |
|
321 case OsErrorMessage.KERR_DISMOUNTED: |
|
322 { |
|
323 throw new PIMException(ErrorString.ITEM_DOES_NOT_BELONG_TO_A_LIST, |
|
324 PIMException.GENERAL_ERROR); |
|
325 } |
|
326 case OsErrorMessage.KERR_NO_MEMORY: |
|
327 { |
|
328 throw new OutOfMemoryError(); |
|
329 } |
|
330 default: |
|
331 { |
|
332 throw new PIMException(ErrorString.GENERAL_ERROR, |
|
333 PIMException.GENERAL_ERROR); |
|
334 } |
|
335 } |
|
336 } |
|
337 |
|
338 public static void handleRemoveItemError(int aNativeErrorCode) throws PIMException |
|
339 { |
|
340 switch (aNativeErrorCode) |
|
341 { |
|
342 case OsErrorMessage.SUCCESS: |
|
343 { |
|
344 return; // OK |
|
345 } |
|
346 case OsErrorMessage.KERR_SESSION_CLOSED: |
|
347 { |
|
348 throw new PIMException(ErrorString.REMOVAL_FAILED_COLON + |
|
349 ErrorString.LIST_IS_CLOSED, |
|
350 PIMException.LIST_CLOSED); |
|
351 } |
|
352 case OsErrorMessage.KERR_ARGUMENT: |
|
353 { |
|
354 // It is an interesting situation if we get here, |
|
355 // because the item _was_ found in the Java side list. |
|
356 throw new PIMException(ErrorString.REMOVAL_FAILED_COLON + |
|
357 ErrorString.ITEM_IS_NOT_IN_THE_LIST, |
|
358 PIMException.GENERAL_ERROR); |
|
359 } |
|
360 case OsErrorMessage.KERR_NOT_FOUND: |
|
361 { |
|
362 throw new PIMException(ErrorString.REMOVAL_FAILED_COLON + |
|
363 ErrorString.ITEM_EXISTS_NO_MORE, |
|
364 PIMException.GENERAL_ERROR); |
|
365 } |
|
366 case OsErrorMessage.KERR_IN_USE: |
|
367 { |
|
368 throw new PIMException(ErrorString.ITEM_IN_USE, |
|
369 PIMException.GENERAL_ERROR); |
|
370 } |
|
371 case OsErrorMessage.KERR_NO_MEMORY: |
|
372 { |
|
373 throw new OutOfMemoryError(); |
|
374 } |
|
375 default: |
|
376 { |
|
377 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
378 } |
|
379 } |
|
380 } |
|
381 |
|
382 public static void handlePIMListCloseError(int aNativeErrorCode) |
|
383 throws PIMException |
|
384 { |
|
385 switch (aNativeErrorCode) |
|
386 { |
|
387 case OsErrorMessage.SUCCESS: |
|
388 { |
|
389 // OK |
|
390 return; |
|
391 } |
|
392 case OsErrorMessage.KERR_SESSION_CLOSED: |
|
393 { |
|
394 throw new PIMException(ErrorString.LIST_IS_ALREADY_CLOSED, |
|
395 PIMException.LIST_CLOSED); |
|
396 } |
|
397 default: |
|
398 { |
|
399 throw new PIMException(ErrorString.GENERAL_ERROR, |
|
400 PIMException.GENERAL_ERROR); |
|
401 } |
|
402 } |
|
403 } |
|
404 |
|
405 public static void handleArrayElementLabelError(int aNativeErrorCode) |
|
406 { |
|
407 switch (aNativeErrorCode) |
|
408 { |
|
409 case OsErrorMessage.SUCCESS: |
|
410 { |
|
411 // OK |
|
412 return; |
|
413 } |
|
414 case OsErrorMessage.KERR_ARGUMENT: |
|
415 { |
|
416 throw new IllegalArgumentException(ErrorString.CANNOT_OBTAIN_LABEL_COLON + |
|
417 ErrorString.INVALID_FIELD_OR_ARRAY_ELEMENT); |
|
418 } |
|
419 case OsErrorMessage.KERR_NOT_SUPPORTED: |
|
420 { |
|
421 throw new UnsupportedFieldException(ErrorString.CANNOT_OBTAIN_LABEL_COLON + |
|
422 ErrorString.UNSUPPORTED_FIELD_OR_ARRAY_ELEMENT); |
|
423 } |
|
424 case OsErrorMessage.KERR_NO_MEMORY: |
|
425 { |
|
426 throw new OutOfMemoryError(); |
|
427 } |
|
428 default: |
|
429 { |
|
430 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
431 } |
|
432 } |
|
433 } |
|
434 |
|
435 public static void handlegetAttributeLabelError(int aNativeErrorCode, |
|
436 int aAttribute) |
|
437 { |
|
438 switch (aNativeErrorCode) |
|
439 { |
|
440 case OsErrorMessage.SUCCESS: |
|
441 { |
|
442 // OK |
|
443 return; |
|
444 } |
|
445 case OsErrorMessage.KERR_ARGUMENT: |
|
446 { |
|
447 throw new IllegalArgumentException(ErrorString.CANNOT_OBTAIN_LABEL_COLON + |
|
448 ErrorString.INVALID_ATTRIBUTE_COLON |
|
449 + aAttribute); |
|
450 } |
|
451 case OsErrorMessage.KERR_NOT_SUPPORTED: |
|
452 { |
|
453 throw new UnsupportedFieldException(ErrorString.CANNOT_OBTAIN_LABEL_COLON + |
|
454 ErrorString.UNSUPPORTED_ATTRIBUTE_COLON |
|
455 + aAttribute, aAttribute); |
|
456 } |
|
457 case OsErrorMessage.KERR_NO_MEMORY: |
|
458 { |
|
459 throw new OutOfMemoryError(); |
|
460 } |
|
461 default: |
|
462 { |
|
463 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
464 } |
|
465 } |
|
466 } |
|
467 |
|
468 public static void handleUpdateListError(int aNativeErrorCode) throws PIMException |
|
469 { |
|
470 switch (aNativeErrorCode) |
|
471 { |
|
472 case OsErrorMessage.SUCCESS: |
|
473 { |
|
474 // OK |
|
475 return; |
|
476 } |
|
477 case OsErrorMessage.KERR_SESSION_CLOSED: |
|
478 { |
|
479 throw new PIMException(ErrorString.UPDATING_FAILED + |
|
480 ErrorString.LIST_IS_CLOSED, |
|
481 PIMException.LIST_CLOSED); |
|
482 } |
|
483 case OsErrorMessage.KERR_NO_MEMORY: |
|
484 // fall to default |
|
485 case OsErrorMessage.KERR_CORRUPT: |
|
486 // fall to default |
|
487 default: |
|
488 { |
|
489 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
490 } |
|
491 } |
|
492 } |
|
493 |
|
494 public static void handleProcessItemResultsError(int aNativeErrorCode) |
|
495 throws PIMException |
|
496 { |
|
497 switch (aNativeErrorCode) |
|
498 { |
|
499 case OsErrorMessage.SUCCESS: |
|
500 { |
|
501 // OK |
|
502 break; |
|
503 } |
|
504 case OsErrorMessage.KERR_SESSION_CLOSED: |
|
505 { |
|
506 throw new PIMException(ErrorString.LIST_IS_CLOSED, |
|
507 PIMException.LIST_CLOSED); |
|
508 } |
|
509 case OsErrorMessage.KERR_ARGUMENT: |
|
510 { |
|
511 throw new IllegalArgumentException(ErrorString.INVALID_ARGUMENT); |
|
512 } |
|
513 case OsErrorMessage.KERR_NO_MEMORY: |
|
514 { |
|
515 throw new OutOfMemoryError(); |
|
516 } |
|
517 default: |
|
518 { |
|
519 throw new PIMException(ErrorString.GENERAL_ERROR, |
|
520 PIMException.GENERAL_ERROR); |
|
521 } |
|
522 } |
|
523 } |
|
524 |
|
525 public static void handleListPIMListError(int aNativeErrorCode) |
|
526 { |
|
527 switch (aNativeErrorCode) |
|
528 { |
|
529 case OsErrorMessage.SUCCESS: |
|
530 { |
|
531 // OK |
|
532 return; |
|
533 } |
|
534 case OsErrorMessage.KERR_ARGUMENT: |
|
535 { |
|
536 // Shouldn't happen because arguments are prechecked |
|
537 throw new java.lang.IllegalArgumentException(ErrorString.INVALID_ARGUMENT); |
|
538 } |
|
539 case OsErrorMessage.KERR_NO_MEMORY: |
|
540 { |
|
541 throw new OutOfMemoryError(); |
|
542 } |
|
543 default: |
|
544 { |
|
545 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
546 } |
|
547 } |
|
548 } |
|
549 |
|
550 public static void handleOpenPIMListError(int aNativeErrorCode, int aPimListType, |
|
551 String aName) throws PIMException |
|
552 { |
|
553 switch (aNativeErrorCode) |
|
554 { |
|
555 // error code |
|
556 case OsErrorMessage.SUCCESS: |
|
557 { |
|
558 // OK |
|
559 return; |
|
560 } |
|
561 case OsErrorMessage.KERR_ARGUMENT: |
|
562 { |
|
563 // This should never happen, because the arguments |
|
564 // have been pre-checked before delegation to native side |
|
565 throw new java.lang.IllegalArgumentException(ErrorString.INVALID_ARGUMENT); |
|
566 } |
|
567 case OsErrorMessage.KERR_NOT_SUPPORTED: |
|
568 { |
|
569 throw new PIMException("List type " + aPimListType |
|
570 + " is not supported.", PIMException.FEATURE_NOT_SUPPORTED); |
|
571 } |
|
572 case OsErrorMessage.KERR_NOT_FOUND: |
|
573 { |
|
574 throw new PIMException(ErrorString.INVALID_LIST_NAME_COLON + aName, |
|
575 PIMException.GENERAL_ERROR); |
|
576 } |
|
577 case OsErrorMessage.KERR_ALREADY_EXISTS: |
|
578 { |
|
579 throw new PIMException(ErrorString.LIST_IS_ALREADY_OPEN, |
|
580 PIMException.GENERAL_ERROR); |
|
581 } |
|
582 case OsErrorMessage.KERR_NO_MEMORY: |
|
583 { |
|
584 throw new OutOfMemoryError(); |
|
585 } |
|
586 default: |
|
587 { |
|
588 throw new PIMException(ErrorString.GENERAL_ERROR, |
|
589 PIMException.GENERAL_ERROR); |
|
590 } |
|
591 } |
|
592 } |
|
593 |
|
594 public static void handleToSerialFormatError(int aNativeErrorCode) |
|
595 throws PIMException |
|
596 { |
|
597 if (aNativeErrorCode == OsErrorMessage.KERR_NO_MEMORY) |
|
598 { |
|
599 throw new OutOfMemoryError(); |
|
600 } |
|
601 else if (aNativeErrorCode != OsErrorMessage.SUCCESS) |
|
602 { |
|
603 throw new PIMException(ErrorString.DATA_SERIALIZATION_FAILED_COLON + |
|
604 ErrorString.ITEM_HAS_INVALID_DATA, |
|
605 PIMException.GENERAL_ERROR); |
|
606 } |
|
607 } |
|
608 |
|
609 /** |
|
610 * Common native-originating error handling for RepeatRule field handling |
|
611 * operations. Note that error handling for RepeatRule field handling |
|
612 * operations differ from those in PIMItem and PIMList. |
|
613 */ |
|
614 public static void handleRRFieldHandlingError(int aNativeErrorCode, |
|
615 int aField) |
|
616 { |
|
617 if (aNativeErrorCode == OsErrorMessage.SUCCESS) |
|
618 { |
|
619 return; // OK |
|
620 } |
|
621 |
|
622 switch (aNativeErrorCode) |
|
623 { |
|
624 case OsErrorMessage.KERR_ARGUMENT: |
|
625 { |
|
626 throw new IllegalArgumentException(ErrorString.INVALID_FIELD_COLON |
|
627 + aField); |
|
628 } |
|
629 case OsErrorMessage.KERR_NOT_FOUND: |
|
630 { |
|
631 throw new FieldEmptyException(ErrorString.FIELD_NOT_FOUND_COLON + aField); |
|
632 } |
|
633 case OsErrorMessage.KERR_TOO_BIG: |
|
634 { |
|
635 throw new IllegalArgumentException(ErrorString.INVALID_VALUE); |
|
636 } |
|
637 case OsErrorMessage.KERR_NO_MEMORY: |
|
638 { |
|
639 throw new OutOfMemoryError(); |
|
640 } |
|
641 default: |
|
642 { |
|
643 throw new GenericException(ErrorString.GENERAL_ERROR_COLON + aNativeErrorCode); |
|
644 } |
|
645 } |
|
646 } |
|
647 |
|
648 /** |
|
649 * Construction prohibited. |
|
650 */ |
|
651 private NativeError() |
|
652 { |
|
653 } |
|
654 |
|
655 } |