wasCSharpSQLite – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * TclPosixException.java --
3 *
4 * This file implements the TclPosixException class, used to report posix
5 * errors in Tcl scripts.
6 *
7 * Copyright (c) 1997 Sun Microsystems, Inc.
8 *
9 * See the file "license.terms" for information on usage and
10 * redistribution of this file, and for a DISCLAIMER OF ALL
11 * WARRANTIES.
12 *
13 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
14 *
15 * RCS @(#) $Id: TclPosixException.java,v 1.2 2001/11/22 00:08:36 mdejong Exp $
16 *
17 */
18 using System;
19 namespace tcl.lang
20 {
21  
22 /*
23 * This class implements exceptions used to report posix errors in Tcl scripts.
24 */
25  
26 class TclPosixException : TclException
27 {
28  
29 internal const int EPERM = 1; /* Operation not permitted */
30 internal const int ENOENT = 2; /* No such file or directory */
31 internal const int ESRCH = 3; /* No such process */
32 internal const int EINTR = 4; /* Interrupted system call */
33 internal const int EIO = 5; /* Input/output error */
34 internal const int ENXIO = 6; /* Device not configured */
35 internal const int E2BIG = 7; /* Argument list too long */
36 internal const int ENOEXEC = 8; /* Exec format error */
37 internal const int EBADF = 9; /* Bad file descriptor */
38 internal const int ECHILD = 10; /* No child processes */
39 internal const int EDEADLK = 11; /* Resource deadlock avoided */
40 /* 11 was EAGAIN */
41 internal const int ENOMEM = 12; /* Cannot allocate memory */
42 internal const int EACCES = 13; /* Permission denied */
43 internal const int EFAULT = 14; /* Bad address */
44 internal const int ENOTBLK = 15; /* Block device required */
45 internal const int EBUSY = 16; /* Device busy */
46 internal const int EEXIST = 17; /* File exists */
47 internal const int EXDEV = 18; /* Cross-device link */
48 internal const int ENODEV = 19; /* Operation not supported by device */
49 internal const int ENOTDIR = 20; /* Not a directory */
50 internal const int EISDIR = 21; /* Is a directory */
51 internal const int EINVAL = 22; /* Invalid argument */
52 internal const int ENFILE = 23; /* Too many open files in system */
53 internal const int EMFILE = 24; /* Too many open files */
54 internal const int ENOTTY = 25; /* Inappropriate ioctl for device */
55 internal const int ETXTBSY = 26; /* Text file busy */
56 internal const int EFBIG = 27; /* File too large */
57 internal const int ENOSPC = 28; /* No space left on device */
58 internal const int ESPIPE = 29; /* Illegal seek */
59 internal const int EROFS = 30; /* Read-only file system */
60 internal const int EMLINK = 31; /* Too many links */
61 internal const int EPIPE = 32; /* Broken pipe */
62 internal const int EDOM = 33; /* Numerical argument out of domain */
63 internal const int ERANGE = 34; /* Result too large */
64 internal const int EAGAIN = 35; /* Resource temporarily unavailable */
65 internal const int EWOULDBLOCK = EAGAIN; /* Operation would block */
66 internal const int EINPROGRESS = 36; /* Operation now in progress */
67 internal const int EALREADY = 37; /* Operation already in progress */
68 internal const int ENOTSOCK = 38; /* Socket operation on non-socket */
69 internal const int EDESTADDRREQ = 39; /* Destination address required */
70 internal const int EMSGSIZE = 40; /* Message too long */
71 internal const int EPROTOTYPE = 41; /* Protocol wrong type for socket */
72 internal const int ENOPROTOOPT = 42; /* Protocol not available */
73 internal const int EPROTONOSUPPORT = 43; /* Protocol not supported */
74 internal const int ESOCKTNOSUPPORT = 44; /* Socket type not supported */
75 internal const int EOPNOTSUPP = 45; /* Operation not supported on socket */
76 internal const int EPFNOSUPPORT = 46; /* Protocol family not supported */
77 internal const int EAFNOSUPPORT = 47; /* Address family not supported by
78 /* protocol family */
79 internal const int EADDRINUSE = 48; /* Address already in use */
80 internal const int EADDRNOTAVAIL = 49; /* Can't assign requested
81 /* address */
82 internal const int ENETDOWN = 50; /* Network is down */
83 internal const int ENETUNREACH = 51; /* Network is unreachable */
84 internal const int ENETRESET = 52; /* Network dropped connection on reset */
85 internal const int ECONNABORTED = 53; /* Software caused connection abort */
86 internal const int ECONNRESET = 54; /* Connection reset by peer */
87 internal const int ENOBUFS = 55; /* No buffer space available */
88 internal const int EISCONN = 56; /* Socket is already connected */
89 internal const int ENOTCONN = 57; /* Socket is not connected */
90 internal const int ESHUTDOWN = 58; /* Can't send after socket shutdown */
91 internal const int ETOOMANYREFS = 59; /* Too many references: can't splice */
92 internal const int ETIMEDOUT = 60; /* Connection timed out */
93 internal const int ECONNREFUSED = 61; /* Connection refused */
94 internal const int ELOOP = 62; /* Too many levels of symbolic links */
95 internal const int ENAMETOOLONG = 63; /* File name too long */
96 internal const int EHOSTDOWN = 64; /* Host is down */
97 internal const int EHOSTUNREACH = 65; /* No route to host */
98 internal const int ENOTEMPTY = 66; /* Directory not empty */
99 internal const int EPROCLIM = 67; /* Too many processes */
100 internal const int EUSERS = 68; /* Too many users */
101 internal const int EDQUOT = 69; /* Disc quota exceeded */
102 internal const int ESTALE = 70; /* Stale NFS file handle */
103 internal const int EREMOTE = 71; /* Too many levels of remote in path */
104 internal const int EBADRPC = 72; /* RPC struct is bad */
105 internal const int ERPCMISMATCH = 73; /* RPC version wrong */
106 internal const int EPROGUNAVAIL = 74; /* RPC prog. not avail */
107 internal const int EPROGMISMATCH = 75; /* Program version wrong */
108 internal const int EPROCUNAVAIL = 76; /* Bad procedure for program */
109 internal const int ENOLCK = 77; /* No locks available */
110 internal const int ENOSYS = 78; /* Function not implemented */
111 internal const int EFTYPE = 79; /* Inappropriate file type or format */
112  
113  
114  
115 public TclPosixException( Interp interp, int errno, string errorMsg )
116 : base( TCL.CompletionCode.ERROR )
117 {
118  
119 string msg = getPosixMsg( errno );
120  
121 TclObject threeEltListObj = TclList.newInstance();
122 TclList.append( interp, threeEltListObj, TclString.newInstance( "POSIX" ) );
123 TclList.append( interp, threeEltListObj, TclString.newInstance( getPosixId( errno ) ) );
124 TclList.append( interp, threeEltListObj, TclString.newInstance( msg ) );
125  
126 interp.setErrorCode( threeEltListObj );
127  
128 if ( interp != null )
129 {
130 interp.setResult( errorMsg );
131 }
132 }
133  
134 public TclPosixException( Interp interp, int errno, bool appendPosixMsg, string errorMsg )
135 : base( TCL.CompletionCode.ERROR )
136 {
137  
138 string msg = getPosixMsg( errno );
139  
140 TclObject threeEltListObj = TclList.newInstance();
141 TclList.append( interp, threeEltListObj, TclString.newInstance( "POSIX" ) );
142 TclList.append( interp, threeEltListObj, TclString.newInstance( getPosixId( errno ) ) );
143 TclList.append( interp, threeEltListObj, TclString.newInstance( msg ) );
144  
145 interp.setErrorCode( threeEltListObj );
146  
147 if ( interp != null )
148 {
149 if ( appendPosixMsg )
150 {
151 interp.setResult( errorMsg + ": " + msg );
152 }
153 else
154 {
155 interp.setResult( errorMsg );
156 }
157 }
158 }
159 private static string getPosixId( int errno )
160 // Code of posix error.
161 {
162 switch ( errno )
163 {
164  
165 case E2BIG:
166 return "E2BIG";
167  
168 case EACCES:
169 return "EACCES";
170  
171 case EADDRINUSE:
172 return "EADDRINUSE";
173  
174 case EADDRNOTAVAIL:
175 return "EADDRNOTAVAIL";
176 //case EADV: return "EADV";
177  
178 case EAFNOSUPPORT:
179 return "EAFNOSUPPORT";
180  
181 case EAGAIN:
182 return "EAGAIN";
183 //case EALIGN: return "EALIGN";
184  
185 case EALREADY:
186 return "EALREADY";
187 //case EBADE: return "EBADE";
188  
189 case EBADF:
190 return "EBADF";
191 //case EBADFD: return "EBADFD";
192 //case EBADMSG: return "EBADMSG";
193 //case EBADR: return "EBADR";
194  
195 case EBADRPC:
196 return "EBADRPC";
197 //case EBADRQC: return "EBADRQC";
198 //case EBADSLT: return "EBADSLT";
199 //case EBFONT: return "EBFONT";
200  
201 case EBUSY:
202 return "EBUSY";
203  
204 case ECHILD:
205 return "ECHILD";
206 //case ECHRNG: return "ECHRNG";
207 //case ECOMM: return "ECOMM";
208  
209 case ECONNABORTED:
210 return "ECONNABORTED";
211  
212 case ECONNREFUSED:
213 return "ECONNREFUSED";
214  
215 case ECONNRESET:
216 return "ECONNRESET";
217  
218 case EDEADLK:
219 return "EDEADLK";
220 //case EDEADLOCK: return "EDEADLOCK";
221  
222 case EDESTADDRREQ:
223 return "EDESTADDRREQ";
224 //case EDIRTY: return "EDIRTY";
225  
226 case EDOM:
227 return "EDOM";
228 //case EDOTDOT: return "EDOTDOT";
229  
230 case EDQUOT:
231 return "EDQUOT";
232 //case EDUPPKG: return "EDUPPKG";
233  
234 case EEXIST:
235 return "EEXIST";
236  
237 case EFAULT:
238 return "EFAULT";
239  
240 case EFBIG:
241 return "EFBIG";
242  
243 case EHOSTDOWN:
244 return "EHOSTDOWN";
245  
246 case EHOSTUNREACH:
247 return "EHOSTUNREACH";
248 //case EIDRM: return "EIDRM";
249 //case EINIT: return "EINIT";
250  
251 case EINPROGRESS:
252 return "EINPROGRESS";
253  
254 case EINTR:
255 return "EINTR";
256  
257 case EINVAL:
258 return "EINVAL";
259  
260 case EIO:
261 return "EIO";
262  
263 case EISCONN:
264 return "EISCONN";
265  
266 case EISDIR:
267 return "EISDIR";
268 //case EISNAM: return "EISNAM";
269 //case ELBIN: return "ELBIN";
270 //case EL2HLT: return "EL2HLT";
271 //case EL2NSYNC: return "EL2NSYNC";
272 //case EL3HLT: return "EL3HLT";
273 //case EL3RST: return "EL3RST";
274 //case ELIBACC: return "ELIBACC";
275 //case ELIBBAD: return "ELIBBAD";
276 //case ELIBEXEC: return "ELIBEXEC";
277 //case ELIBMAX: return "ELIBMAX";
278 //case ELIBSCN: return "ELIBSCN";
279 //case ELNRNG: return "ELNRNG";
280  
281 case ELOOP:
282 return "ELOOP";
283  
284 case EMLINK:
285 return "EMLINK";
286  
287 case EMSGSIZE:
288 return "EMSGSIZE";
289 //case EMULTIHOP: return "EMULTIHOP";
290  
291 case ENAMETOOLONG:
292 return "ENAMETOOLONG";
293 //case ENAVAIL: return "ENAVAIL";
294 //case ENET: return "ENET";
295  
296 case ENETDOWN:
297 return "ENETDOWN";
298  
299 case ENETRESET:
300 return "ENETRESET";
301  
302 case ENETUNREACH:
303 return "ENETUNREACH";
304  
305 case ENFILE:
306 return "ENFILE";
307 //case ENOANO: return "ENOANO";
308  
309 case ENOBUFS:
310 return "ENOBUFS";
311 //case ENOCSI: return "ENOCSI";
312 //case ENODATA: return "ENODATA";
313  
314 case ENODEV:
315 return "ENODEV";
316  
317 case ENOENT:
318 return "ENOENT";
319  
320 case ENOEXEC:
321 return "ENOEXEC";
322  
323 case ENOLCK:
324 return "ENOLCK";
325 //case ENOLINK: return "ENOLINK";
326  
327 case ENOMEM:
328 return "ENOMEM";
329 //case ENOMSG: return "ENOMSG";
330 //case ENONET: return "ENONET";
331 //case ENOPKG: return "ENOPKG";
332  
333 case ENOPROTOOPT:
334 return "ENOPROTOOPT";
335  
336 case ENOSPC:
337 return "ENOSPC";
338 //case ENOSR: return "ENOSR";
339 //case ENOSTR: return "ENOSTR";
340 //case ENOSYM: return "ENOSYM";
341  
342 case ENOSYS:
343 return "ENOSYS";
344  
345 case ENOTBLK:
346 return "ENOTBLK";
347  
348 case ENOTCONN:
349 return "ENOTCONN";
350  
351 case ENOTDIR:
352 return "ENOTDIR";
353  
354 case ENOTEMPTY:
355 return "ENOTEMPTY";
356 //case ENOTNAM: return "ENOTNAM";
357  
358 case ENOTSOCK:
359 return "ENOTSOCK";
360 //case ENOTSUP: return "ENOTSUP";
361  
362 case ENOTTY:
363 return "ENOTTY";
364 //case ENOTUNIQ: return "ENOTUNIQ";
365  
366 case ENXIO:
367 return "ENXIO";
368  
369 case EOPNOTSUPP:
370 return "EOPNOTSUPP";
371  
372 case EPERM:
373 return "EPERM";
374  
375 case EPFNOSUPPORT:
376 return "EPFNOSUPPORT";
377  
378 case EPIPE:
379 return "EPIPE";
380  
381 case EPROCLIM:
382 return "EPROCLIM";
383  
384 case EPROCUNAVAIL:
385 return "EPROCUNAVAIL";
386  
387 case EPROGMISMATCH:
388 return "EPROGMISMATCH";
389  
390 case EPROGUNAVAIL:
391 return "EPROGUNAVAIL";
392 //case EPROTO: return "EPROTO";
393  
394 case EPROTONOSUPPORT:
395 return "EPROTONOSUPPORT";
396  
397 case EPROTOTYPE:
398 return "EPROTOTYPE";
399  
400 case ERANGE:
401 return "ERANGE";
402 //case EREFUSED: return "EREFUSED";
403 //case EREMCHG: return "EREMCHG";
404 //case EREMDEV: return "EREMDEV";
405  
406 case EREMOTE:
407 return "EREMOTE";
408 //case EREMOTEIO: return "EREMOTEIO";
409 //case EREMOTERELEASE: return "EREMOTERELEASE";
410  
411 case EROFS:
412 return "EROFS";
413  
414 case ERPCMISMATCH:
415 return "ERPCMISMATCH";
416 //case ERREMOTE: return "ERREMOTE";
417  
418 case ESHUTDOWN:
419 return "ESHUTDOWN";
420  
421 case ESOCKTNOSUPPORT:
422 return "ESOCKTNOSUPPORT";
423  
424 case ESPIPE:
425 return "ESPIPE";
426  
427 case ESRCH:
428 return "ESRCH";
429 //case ESRMNT: return "ESRMNT";
430  
431 case ESTALE:
432 return "ESTALE";
433 //case ESUCCESS: return "ESUCCESS";
434 //case ETIME: return "ETIME";
435  
436 case ETIMEDOUT:
437 return "ETIMEDOUT";
438  
439 case ETOOMANYREFS:
440 return "ETOOMANYREFS";
441  
442 case ETXTBSY:
443 return "ETXTBSY";
444 //case EUCLEAN: return "EUCLEAN";
445 //case EUNATCH: return "EUNATCH";
446  
447 case EUSERS:
448 return "EUSERS";
449 //case EVERSION: return "EVERSION";
450 //case EWOULDBLOCK: return "EWOULDBLOCK";
451  
452 case EXDEV:
453 return "EXDEV";
454 //case EXFULL: return "EXFULL";
455 }
456 return "unknown error";
457 }
458 internal static string getPosixMsg( int errno )
459 // Code of posix error.
460 {
461 switch ( errno )
462 {
463  
464 case E2BIG:
465 return "argument list too long";
466  
467 case EACCES:
468 return "permission denied";
469  
470 case EADDRINUSE:
471 return "address already in use";
472  
473 case EADDRNOTAVAIL:
474 return "can't assign requested address";
475 //case EADV: return "advertise error";
476  
477 case EAFNOSUPPORT:
478 return "address family not supported by protocol family";
479  
480 case EAGAIN:
481 return "resource temporarily unavailable";
482 //case EALIGN: return "EALIGN";
483  
484 case EALREADY:
485 return "operation already in progress";
486 //case EBADE: return "bad exchange descriptor";
487  
488 case EBADF:
489 return "bad file number";
490 //case EBADFD: return "file descriptor in bad state";
491 //case EBADMSG: return "not a data message";
492 //case EBADR: return "bad request descriptor";
493  
494 case EBADRPC:
495 return "RPC structure is bad";
496 //case EBADRQC: return "bad request code";
497 //case EBADSLT: return "invalid slot";
498 //case EBFONT: return "bad font file format";
499  
500 case EBUSY:
501 return "file busy";
502  
503 case ECHILD:
504 return "no children";
505 //case ECHRNG: return "channel number out of range";
506 //case ECOMM: return "communication error on send";
507  
508 case ECONNABORTED:
509 return "software caused connection abort";
510  
511 case ECONNREFUSED:
512 return "connection refused";
513  
514 case ECONNRESET:
515 return "connection reset by peer";
516  
517 case EDEADLK:
518 return "resource deadlock avoided";
519 //case EDEADLOCK: return "resource deadlock avoided";
520  
521 case EDESTADDRREQ:
522 return "destination address required";
523 //case EDIRTY: return "mounting a dirty fs w/o force";
524  
525 case EDOM:
526 return "math argument out of range";
527 //case EDOTDOT: return "cross mount point";
528  
529 case EDQUOT:
530 return "disk quota exceeded";
531 //case EDUPPKG: return "duplicate package name";
532  
533 case EEXIST:
534 return "file already exists";
535  
536 case EFAULT:
537 return "bad address in system call argument";
538  
539 case EFBIG:
540 return "file too large";
541  
542 case EHOSTDOWN:
543 return "host is down";
544  
545 case EHOSTUNREACH:
546 return "host is unreachable";
547 //case EIDRM: return "identifier removed";
548 //case EINIT: return "initialization error";
549  
550 case EINPROGRESS:
551 return "operation now in progress";
552  
553 case EINTR:
554 return "interrupted system call";
555  
556 case EINVAL:
557 return "invalid argument";
558  
559 case EIO:
560 return "I/O error";
561  
562 case EISCONN:
563 return "socket is already connected";
564  
565 case EISDIR:
566 return "illegal operation on a directory";
567 //case EISNAM: return "is a name file";
568 //case ELBIN: return "ELBIN";
569 //case EL2HLT: return "level 2 halted";
570 //case EL2NSYNC: return "level 2 not synchronized";
571 //case EL3HLT: return "level 3 halted";
572 //case EL3RST: return "level 3 reset";
573 //case ELIBACC: return "can not access a needed shared library";
574 //case ELIBBAD: return "accessing a corrupted shared library";
575 //case ELIBEXEC: return "can not exec a shared library directly";
576 //case ELIBMAX: return
577 //"attempting to link in more shared libraries than system limit";
578 //case ELIBSCN: return ".lib section in a.out corrupted";
579 //case ELNRNG: return "link number out of range";
580  
581 case ELOOP:
582 return "too many levels of symbolic links";
583  
584 case EMFILE:
585 return "too many open files";
586  
587 case EMLINK:
588 return "too many links";
589  
590 case EMSGSIZE:
591 return "message too long";
592 //case EMULTIHOP: return "multihop attempted";
593  
594 case ENAMETOOLONG:
595 return "file name too long";
596 //case ENAVAIL: return "not available";
597 //case ENET: return "ENET";
598  
599 case ENETDOWN:
600 return "network is down";
601  
602 case ENETRESET:
603 return "network dropped connection on reset";
604  
605 case ENETUNREACH:
606 return "network is unreachable";
607  
608 case ENFILE:
609 return "file table overflow";
610 //case ENOANO: return "anode table overflow";
611  
612 case ENOBUFS:
613 return "no buffer space available";
614 //case ENOCSI: return "no CSI structure available";
615 //case ENODATA: return "no data available";
616  
617 case ENODEV:
618 return "no such device";
619  
620 case ENOENT:
621 return "no such file or directory";
622  
623 case ENOEXEC:
624 return "exec format error";
625  
626 case ENOLCK:
627 return "no locks available";
628 //case ENOLINK: return "link has be severed";
629  
630 case ENOMEM:
631 return "not enough memory";
632 //case ENOMSG: return "no message of desired type";
633 //case ENONET: return "machine is not on the network";
634 //case ENOPKG: return "package not installed";
635  
636 case ENOPROTOOPT:
637 return "bad proocol option";
638  
639 case ENOSPC:
640 return "no space left on device";
641 //case ENOSR: return "out of stream resources";
642 //case ENOSTR: return "not a stream device";
643 //case ENOSYM: return "unresolved symbol name";
644  
645 case ENOSYS:
646 return "function not implemented";
647  
648 case ENOTBLK:
649 return "block device required";
650  
651 case ENOTCONN:
652 return "socket is not connected";
653  
654 case ENOTDIR:
655 return "not a directory";
656  
657 case ENOTEMPTY:
658 return "directory not empty";
659 //case ENOTNAM: return "not a name file";
660  
661 case ENOTSOCK:
662 return "socket operation on non-socket";
663 //case ENOTSUP: return "operation not supported";
664  
665 case ENOTTY:
666 return "inappropriate device for ioctl";
667 //case ENOTUNIQ: return "name not unique on network";
668  
669 case ENXIO:
670 return "no such device or address";
671  
672 case EOPNOTSUPP:
673 return "operation not supported on socket";
674  
675 case EPERM:
676 return "not owner";
677  
678 case EPFNOSUPPORT:
679 return "protocol family not supported";
680  
681 case EPIPE:
682 return "broken pipe";
683  
684 case EPROCLIM:
685 return "too many processes";
686  
687 case EPROCUNAVAIL:
688 return "bad procedure for program";
689  
690 case EPROGMISMATCH:
691 return "program version wrong";
692  
693 case EPROGUNAVAIL:
694 return "RPC program not available";
695 //case EPROTO: return "protocol error";
696  
697 case EPROTONOSUPPORT:
698 return "protocol not suppored";
699  
700 case EPROTOTYPE:
701 return "protocol wrong type for socket";
702  
703 case ERANGE:
704 return "math result unrepresentable";
705 //case EREFUSED: return "EREFUSED";
706 //case EREMCHG: return "remote address changed";
707 //case EREMDEV: return "remote device";
708  
709 case EREMOTE:
710 return "pathname hit remote file system";
711 //case EREMOTEIO: return "remote i/o error";
712 //case EREMOTERELEASE: return "EREMOTERELEASE";
713  
714 case EROFS:
715 return "read-only file system";
716  
717 case ERPCMISMATCH:
718 return "RPC version is wrong";
719 //case ERREMOTE: return "object is remote";
720  
721 case ESHUTDOWN:
722 return "can't send afer socket shutdown";
723  
724 case ESOCKTNOSUPPORT:
725 return "socket type not supported";
726  
727 case ESPIPE:
728 return "invalid seek";
729  
730 case ESRCH:
731 return "no such process";
732 //case ESRMNT: return "srmount error";
733  
734 case ESTALE:
735 return "stale remote file handle";
736 //case ESUCCESS: return "Error 0";
737 //case ETIME: return "timer expired";
738  
739 case ETIMEDOUT:
740 return "connection timed out";
741  
742 case ETOOMANYREFS:
743 return "too many references: can't splice";
744  
745 case ETXTBSY:
746 return "text file or pseudo-device busy";
747 //case EUCLEAN: return "structure needs cleaning";
748 //case EUNATCH: return "protocol driver not attached";
749  
750 case EUSERS:
751 return "too many users";
752 //case EVERSION: return "version mismatch";
753 //case EWOULDBLOCK: return "operation would block";
754  
755 case EXDEV:
756 return "cross-domain link";
757 //case EXFULL: return "message tables full";
758  
759 default:
760 return "unknown POSIX error";
761  
762 }
763 }
764 } // end TclPosixException class
765 }