1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  * ident	"%Z%%M%	%I%	%E% SMI"
27  */
28 
29 package com.sun.solaris.service.pools;
30 
31 /**
32  * The <code>PoolsException</code> class represents a pools error.  It
33  * is used to report any errors in native code.  See
34  * <code>errno(3C)</code> for information on the system (POE_SYSTEM)
35  * error codes.
36  */
37 public class PoolsException extends Exception {
38 	/**
39 	 * EPERM.
40 	 */
41 	public static final int EPERM = 1;
42 
43 	/**
44 	 * ENOENT.
45 	 */
46 	public static final int ENOENT = 2;
47 
48 	/**
49 	 * ESRCH.
50 	 */
51 	public static final int ESRCH = 3;
52 
53 	/**
54 	 * EINTR.
55 	 */
56 	public static final int EINTR = 4;
57 
58 	/**
59 	 * EIO.
60 	 */
61 	public static final int EIO = 5;
62 
63 	/**
64 	 * ENXIO.
65 	 */
66 	public static final int ENXIO = 6;
67 
68 	/**
69 	 * E2BIG.
70 	 */
71 	public static final int E2BIG = 7;
72 
73 	/**
74 	 * ENOEXEC.
75 	 */
76 	public static final int ENOEXEC = 8;
77 
78 	/**
79 	 * EBADF.
80 	 */
81 	public static final int EBADF = 9;
82 
83 	/**
84 	 * ECHILD.
85 	 */
86 	public static final int ECHILD = 10;
87 
88 	/**
89 	 * EAGAIN.
90 	 */
91 	public static final int EAGAIN = 11;
92 
93 	/**
94 	 * ENOMEM.
95 	 */
96 	public static final int ENOMEM = 12;
97 
98 	/**
99 	 * EACCES.
100 	 */
101 	public static final int EACCES = 13;
102 
103 	/**
104 	 * EFAULT.
105 	 */
106 	public static final int EFAULT = 14;
107 
108 	/**
109 	 * ENOTBLK.
110 	 */
111 	public static final int ENOTBLK = 15;
112 
113 	/**
114 	 * EBUSY.
115 	 */
116 	public static final int EBUSY = 16;
117 
118 	/**
119 	 * EEXIST.
120 	 */
121 	public static final int EEXIST = 17;
122 
123 	/**
124 	 * EXDEV.
125 	 */
126 	public static final int EXDEV = 18;
127 
128 	/**
129 	 * ENODEV.
130 	 */
131 	public static final int ENODEV = 19;
132 
133 	/**
134 	 * ENOTDIR.
135 	 */
136 	public static final int ENOTDIR = 20;
137 
138 	/**
139 	 * EISDIR.
140 	 */
141 	public static final int EISDIR = 21;
142 
143 	/**
144 	 * EINVAL.
145 	 */
146 	public static final int EINVAL = 22;
147 
148 	/**
149 	 * ENFILE.
150 	 */
151 	public static final int ENFILE = 23;
152 
153 	/**
154 	 * EMFILE.
155 	 */
156 	public static final int EMFILE = 24;
157 
158 	/**
159 	 * ENOTTY.
160 	 */
161 	public static final int ENOTTY = 25;
162 
163 	/**
164 	 * ETXTBSY.
165 	 */
166 	public static final int ETXTBSY = 26;
167 
168 	/**
169 	 * EFBIG.
170 	 */
171 	public static final int EFBIG = 27;
172 
173 	/**
174 	 * ENOSPC.
175 	 */
176 	public static final int ENOSPC = 28;
177 
178 	/**
179 	 * ESPIPE.
180 	 */
181 	public static final int ESPIPE = 29;
182 
183 	/**
184 	 * EROFS.
185 	 */
186 	public static final int EROFS = 30;
187 
188 	/**
189 	 * EMLINK.
190 	 */
191 	public static final int EMLINK = 31;
192 
193 	/**
194 	 * EPIPE.
195 	 */
196 	public static final int EPIPE = 32;
197 
198 	/**
199 	 * EDOM.
200 	 */
201 	public static final int EDOM = 33;
202 
203 	/**
204 	 * ERANGE.
205 	 */
206 	public static final int ERANGE = 34;
207 
208 	/**
209 	 * ENOMSG.
210 	 */
211 	public static final int ENOMSG = 35;
212 
213 	/**
214 	 * EIDRM.
215 	 */
216 	public static final int EIDRM = 36;
217 
218 	/**
219 	 * ECHRNG.
220 	 */
221 	public static final int ECHRNG = 37;
222 
223 	/**
224 	 * EL2NSYNC.
225 	 */
226 	public static final int EL2NSYNC = 38;
227 
228 	/**
229 	 * EL3HLT.
230 	 */
231 	public static final int EL3HLT = 39;
232 
233 	/**
234 	 * EL3RST.
235 	 */
236 	public static final int EL3RST = 40;
237 
238 	/**
239 	 * ELNRNG.
240 	 */
241 	public static final int ELNRNG = 41;
242 
243 	/**
244 	 * EUNATCH.
245 	 */
246 	public static final int EUNATCH = 42;
247 
248 	/**
249 	 * ENOCSI.
250 	 */
251 	public static final int ENOCSI = 43;
252 
253 	/**
254 	 * EL2HLT.
255 	 */
256 	public static final int EL2HLT = 44;
257 
258 	/**
259 	 * EDEADLK.
260 	 */
261 	public static final int EDEADLK = 45;
262 
263 	/**
264 	 * ENOLCK.
265 	 */
266 	public static final int ENOLCK = 46;
267 
268 	/**
269 	 * ECANCELED.
270 	 */
271 	public static final int ECANCELED = 47;
272 
273 	/**
274 	 * ENOTSUP.
275 	 */
276 	public static final int ENOTSUP = 48;
277 
278 	/**
279 	 * EDQUOT.
280 	 */
281 	public static final int EDQUOT = 49;
282 
283 	/**
284 	 * EBADE.
285 	 */
286 	public static final int EBADE = 50;
287 
288 	/**
289 	 * EBADR.
290 	 */
291 	public static final int EBADR = 51;
292 
293 	/**
294 	 * EXFULL.
295 	 */
296 	public static final int EXFULL = 52;
297 
298 	/**
299 	 * ENOANO.
300 	 */
301 	public static final int ENOANO = 53;
302 
303 	/**
304 	 * EBADRQC.
305 	 */
306 	public static final int EBADRQC = 54;
307 
308 	/**
309 	 * EBADSLT.
310 	 */
311 	public static final int EBADSLT = 55;
312 
313 	/**
314 	 * EDEADLOCK.
315 	 */
316 	public static final int EDEADLOCK = 56;
317 
318 	/**
319 	 * EBFONT.
320 	 */
321 	public static final int EBFONT = 57;
322 
323 	/**
324 	 * EOWNERDEAD.
325 	 */
326 	public static final int EOWNERDEAD = 58;
327 
328 	/**
329 	 * ENOTRECOVERABLE.
330 	 */
331 	public static final int ENOTRECOVERABLE = 59;
332 
333 	/**
334 	 * ENOSTR.
335 	 */
336 	public static final int ENOSTR = 60;
337 
338 	/**
339 	 * ENODATA.
340 	 */
341 	public static final int ENODATA = 61;
342 
343 	/**
344 	 * ETIME.
345 	 */
346 	public static final int ETIME = 62;
347 
348 	/**
349 	 * ENOSR.
350 	 */
351 	public static final int ENOSR = 63;
352 
353 	/**
354 	 * ENONET.
355 	 */
356 	public static final int ENONET = 64;
357 
358 	/**
359 	 * ENOPKG.
360 	 */
361 	public static final int ENOPKG = 65;
362 
363 	/**
364 	 * EREMOTE.
365 	 */
366 	public static final int EREMOTE = 66;
367 
368 	/**
369 	 * ENOLINK.
370 	 */
371 	public static final int ENOLINK = 67;
372 
373 	/**
374 	 * EADV.
375 	 */
376 	public static final int EADV = 68;
377 
378 	/**
379 	 * ESRMNT.
380 	 */
381 	public static final int ESRMNT = 69;
382 
383 	/**
384 	 * ECOMM.
385 	 */
386 	public static final int ECOMM = 70;
387 
388 	/**
389 	 * EPROTO.
390 	 */
391 	public static final int EPROTO = 71;
392 
393 	/**
394 	 * ELOCKUNMAPPED.
395 	 */
396 	public static final int ELOCKUNMAPPED = 72;
397 
398 	/**
399 	 * ENOTACTIVE.
400 	 */
401 	public static final int ENOTACTIVE = 73;
402 
403 	/**
404 	 * EMULTIHOP.
405 	 */
406 	public static final int EMULTIHOP = 74;
407 
408 	/**
409 	 * EBADMSG.
410 	 */
411 	public static final int EBADMSG = 77;
412 
413 	/**
414 	 * ENAMETOOLONG.
415 	 */
416 	public static final int ENAMETOOLONG = 78;
417 
418 	/**
419 	 * EOVERFLOW.
420 	 */
421 	public static final int EOVERFLOW = 79;
422 
423 	/**
424 	 * ENOTUNIQ.
425 	 */
426 	public static final int ENOTUNIQ = 80;
427 
428 	/**
429 	 * EBADFD.
430 	 */
431 	public static final int EBADFD = 81;
432 
433 	/**
434 	 * EREMCHG.
435 	 */
436 	public static final int EREMCHG = 82;
437 
438 	/**
439 	 * ELIBACC.
440 	 */
441 	public static final int ELIBACC = 83;
442 
443 	/**
444 	 * ELIBBAD.
445 	 */
446 	public static final int ELIBBAD = 84;
447 
448 	/**
449 	 * ELIBSCN.
450 	 */
451 	public static final int ELIBSCN = 85;
452 
453 	/**
454 	 * ELIBMAX.
455 	 */
456 	public static final int ELIBMAX = 86;
457 
458 	/**
459 	 * ELIBEXEC.
460 	 */
461 	public static final int ELIBEXEC = 87;
462 
463 	/**
464 	 * EILSEQ.
465 	 */
466 	public static final int EILSEQ = 88;
467 
468 	/**
469 	 * ENOSYS.
470 	 */
471 	public static final int ENOSYS = 89;
472 
473 	/**
474 	 * ELOOP.
475 	 */
476 	public static final int ELOOP = 90;
477 
478 	/**
479 	 * ERESTART.
480 	 */
481 	public static final int ERESTART = 91;
482 
483 	/**
484 	 * ESTRPIPE.
485 	 */
486 	public static final int ESTRPIPE = 92;
487 
488 	/**
489 	 * ENOTEMPTY.
490 	 */
491 	public static final int ENOTEMPTY = 93;
492 
493 	/**
494 	 * EUSERS.
495 	 */
496 	public static final int EUSERS = 94;
497 
498 	/**
499 	 * ENOTSOCK.
500 	 */
501 	public static final int ENOTSOCK = 95;
502 
503 	/**
504 	 * EDESTADDRREQ.
505 	 */
506 	public static final int EDESTADDRREQ = 96;
507 
508 	/**
509 	 * EMSGSIZE.
510 	 */
511 	public static final int EMSGSIZE = 97;
512 
513 	/**
514 	 * EPROTOTYPE.
515 	 */
516 	public static final int EPROTOTYPE = 98;
517 
518 	/**
519 	 * ENOPROTOOPT.
520 	 */
521 	public static final int ENOPROTOOPT = 99;
522 
523 	/**
524 	 * EPROTONOSUPPORT.
525 	 */
526 	public static final int EPROTONOSUPPORT = 120;
527 
528 	/**
529 	 * ESOCKTNOSUPPORT.
530 	 */
531 	public static final int ESOCKTNOSUPPORT = 121;
532 
533 	/**
534 	 * EOPNOTSUPP.
535 	 */
536 	public static final int EOPNOTSUPP = 122;
537 
538 	/**
539 	 * EPFNOSUPPORT.
540 	 */
541 	public static final int EPFNOSUPPORT = 123;
542 
543 	/**
544 	 * EAFNOSUPPORT.
545 	 */
546 	public static final int EAFNOSUPPORT = 124;
547 
548 	/**
549 	 * EADDRINUSE.
550 	 */
551 	public static final int EADDRINUSE = 125;
552 
553 	/**
554 	 * EADDRNOTAVAIL.
555 	 */
556 	public static final int EADDRNOTAVAIL = 126;
557 
558 	/**
559 	 * ENETDOWN.
560 	 */
561 	public static final int ENETDOWN = 127;
562 
563 	/**
564 	 * ENETUNREACH.
565 	 */
566 	public static final int ENETUNREACH = 128;
567 
568 	/**
569 	 * ENETRESET.
570 	 */
571 	public static final int ENETRESET = 129;
572 
573 	/**
574 	 * ECONNABORTED.
575 	 */
576 	public static final int ECONNABORTED = 130;
577 
578 	/**
579 	 * ECONNRESET.
580 	 */
581 	public static final int ECONNRESET = 131;
582 
583 	/**
584 	 * ENOBUFS.
585 	 */
586 	public static final int ENOBUFS = 132;
587 
588 	/**
589 	 * EISCONN.
590 	 */
591 	public static final int EISCONN = 133;
592 
593 	/**
594 	 * ENOTCONN.
595 	 */
596 	public static final int ENOTCONN = 134;
597 
598 	/**
599 	 * ESHUTDOWN.
600 	 */
601 	public static final int ESHUTDOWN = 143;
602 
603 	/**
604 	 * ETOOMANYREFS.
605 	 */
606 	public static final int ETOOMANYREFS = 144;
607 
608 	/**
609 	 * ETIMEDOUT.
610 	 */
611 	public static final int ETIMEDOUT = 145;
612 
613 	/**
614 	 * ECONNREFUSED.
615 	 */
616 	public static final int ECONNREFUSED = 146;
617 
618 	/**
619 	 * EHOSTDOWN.
620 	 */
621 	public static final int EHOSTDOWN = 147;
622 
623 	/**
624 	 * EHOSTUNREACH.
625 	 */
626 	public static final int EHOSTUNREACH = 148;
627 
628 	/**
629 	 * EALREADY.
630 	 */
631 	public static final int EALREADY = 149;
632 
633 	/**
634 	 * EINPROGRESS.
635 	 */
636 	public static final int EINPROGRESS = 150;
637 
638 	/**
639 	 * ESTALE.
640 	 */
641 	public static final int ESTALE = 151;
642 
643 	private final int errorCode = PoolInternal.pool_error();
644 
645 	/**
646 	 * Constructor.
647 	 */
PoolsException()648 	public PoolsException()
649 	{
650 		super(description(PoolInternal.pool_error()));
651 	}
652 
description(int errorCode)653 	private static String description(int errorCode)
654 	{
655 		StringBuffer sb = new StringBuffer(PoolInternal.pool_strerror(
656 		    errorCode));
657 		if (errorCode == PoolInternal.POE_SYSTEM)
658 			sb.append(": " + PoolInternal.pool_strerror_sys());
659 		return (sb.toString());
660 	}
661 
662 	/**
663 	 * Returns the native pool error code.
664 	 *
665 	 * @return the native pool error code.
666 	 */
getCode()667 	public int getCode()
668 	{
669 		return (errorCode);
670 	}
671 
672 	/**
673 	 * Returns <code>errno</code>, if the pool error is
674 	 * <code>POE_SYSTEM</code>.
675 	 */
getErrno()676 	public native int getErrno();
677 }
678