1
///////////////////////////////////////////////////////////////////////////
3
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
6
// All rights reserved.
8
// Redistribution and use in source and binary forms, with or without
9
// modification, are permitted provided that the following conditions are
11
// * Redistributions of source code must retain the above copyright
12
// notice, this list of conditions and the following disclaimer.
13
// * Redistributions in binary form must reproduce the above
14
// copyright notice, this list of conditions and the following disclaimer
15
// in the documentation and/or other materials provided with the
17
// * Neither the name of Industrial Light & Magic nor the names of
18
// its contributors may be used to endorse or promote products derived
19
// from this software without specific prior written permission.
21
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
///////////////////////////////////////////////////////////////////////////
37
//----------------------------------------------------------------
39
// Exceptions that correspond to "errno" error codes,
40
// and a function to make throwing those exceptions easy.
42
//----------------------------------------------------------------
44
#include "IexThrowErrnoExc.h"
45
#include "IexErrnoExc.h"
52
void throwErrnoExc (const std::string &text, int errnum)
54
const char *entext = strerror (errnum);
55
std::string tmp (text);
56
std::string::size_type pos;
58
while (std::string::npos != (pos = tmp.find ("%T")))
59
tmp.replace (pos, 2, entext, strlen (entext));
70
throw EnoentExc (tmp);
100
throw EnoexecExc (tmp);
105
throw EbadfExc (tmp);
110
throw EchildExc (tmp);
115
throw EagainExc (tmp);
120
throw EnomemExc (tmp);
125
throw EaccesExc (tmp);
130
throw EfaultExc (tmp);
133
#if defined (ENOTBLK)
135
throw EnotblkExc (tmp);
140
throw EbusyExc (tmp);
145
throw EexistExc (tmp);
150
throw ExdevExc (tmp);
155
throw EnodevExc (tmp);
158
#if defined (ENOTDIR)
160
throw EnotdirExc (tmp);
165
throw EisdirExc (tmp);
170
throw EinvalExc (tmp);
175
throw EnfileExc (tmp);
180
throw EmfileExc (tmp);
185
throw EnottyExc (tmp);
188
#if defined (ETXTBSY)
190
throw EtxtbsyExc (tmp);
195
throw EfbigExc (tmp);
200
throw EnospcExc (tmp);
205
throw EspipeExc (tmp);
210
throw ErofsExc (tmp);
215
throw EmlinkExc (tmp);
220
throw EpipeExc (tmp);
230
throw ErangeExc (tmp);
235
throw EnomsgExc (tmp);
240
throw EidrmExc (tmp);
245
throw EchrngExc (tmp);
248
#if defined (EL2NSYNC)
250
throw El2nsyncExc (tmp);
255
throw El3hltExc (tmp);
260
throw El3rstExc (tmp);
265
throw ElnrngExc (tmp);
268
#if defined (EUNATCH)
270
throw EunatchExc (tmp);
275
throw EnocsiExc (tmp);
280
throw El2hltExc (tmp);
283
#if defined (EDEADLK)
285
throw EdeadlkExc (tmp);
290
throw EnolckExc (tmp);
295
throw EbadeExc (tmp);
300
throw EbadrExc (tmp);
305
throw ExfullExc (tmp);
310
throw EnoanoExc (tmp);
313
#if defined (EBADRQC)
315
throw EbadrqcExc (tmp);
318
#if defined (EBADSLT)
320
throw EbadsltExc (tmp);
323
#if defined (EDEADLOCK) && defined (EDEADLK)
324
#if EDEADLOCK != EDEADLK
326
throw EdeadlockExc (tmp);
328
#elif defined (EDEADLOCK)
330
throw EdeadlockExc (tmp);
335
throw EbfontExc (tmp);
340
throw EnostrExc (tmp);
343
#if defined (ENODATA)
345
throw EnodataExc (tmp);
350
throw EtimeExc (tmp);
355
throw EnosrExc (tmp);
360
throw EnonetExc (tmp);
365
throw EnopkgExc (tmp);
368
#if defined (EREMOTE)
370
throw EremoteExc (tmp);
373
#if defined (ENOLINK)
375
throw EnolinkExc (tmp);
385
throw EsrmntExc (tmp);
390
throw EcommExc (tmp);
395
throw EprotoExc (tmp);
398
#if defined (EMULTIHOP)
400
throw EmultihopExc (tmp);
403
#if defined (EBADMSG)
405
throw EbadmsgExc (tmp);
408
#if defined (ENAMETOOLONG)
410
throw EnametoolongExc (tmp);
413
#if defined (EOVERFLOW)
415
throw EoverflowExc (tmp);
418
#if defined (ENOTUNIQ)
420
throw EnotuniqExc (tmp);
425
throw EbadfdExc (tmp);
428
#if defined (EREMCHG)
430
throw EremchgExc (tmp);
433
#if defined (ELIBACC)
435
throw ElibaccExc (tmp);
438
#if defined (ELIBBAD)
440
throw ElibbadExc (tmp);
443
#if defined (ELIBSCN)
445
throw ElibscnExc (tmp);
448
#if defined (ELIBMAX)
450
throw ElibmaxExc (tmp);
453
#if defined (ELIBEXEC)
455
throw ElibexecExc (tmp);
460
throw EilseqExc (tmp);
465
throw EnosysExc (tmp);
470
throw EloopExc (tmp);
473
#if defined (ERESTART)
475
throw ErestartExc (tmp);
478
#if defined (ESTRPIPE)
480
throw EstrpipeExc (tmp);
483
#if defined (ENOTEMPTY)
485
throw EnotemptyExc (tmp);
490
throw EusersExc (tmp);
493
#if defined (ENOTSOCK)
495
throw EnotsockExc (tmp);
498
#if defined (EDESTADDRREQ)
500
throw EdestaddrreqExc (tmp);
503
#if defined (EMSGSIZE)
505
throw EmsgsizeExc (tmp);
508
#if defined (EPROTOTYPE)
510
throw EprototypeExc (tmp);
513
#if defined (ENOPROTOOPT)
515
throw EnoprotooptExc (tmp);
518
#if defined (EPROTONOSUPPORT)
519
case EPROTONOSUPPORT:
520
throw EprotonosupportExc (tmp);
523
#if defined (ESOCKTNOSUPPORT)
524
case ESOCKTNOSUPPORT:
525
throw EsocktnosupportExc (tmp);
528
#if defined (EOPNOTSUPP)
530
throw EopnotsuppExc (tmp);
533
#if defined (EPFNOSUPPORT)
535
throw EpfnosupportExc (tmp);
538
#if defined (EAFNOSUPPORT)
540
throw EafnosupportExc (tmp);
543
#if defined (EADDRINUSE)
545
throw EaddrinuseExc (tmp);
548
#if defined (EADDRNOTAVAIL)
550
throw EaddrnotavailExc (tmp);
553
#if defined (ENETDOWN)
555
throw EnetdownExc (tmp);
558
#if defined (ENETUNREACH)
560
throw EnetunreachExc (tmp);
563
#if defined (ENETRESET)
565
throw EnetresetExc (tmp);
568
#if defined (ECONNABORTED)
570
throw EconnabortedExc (tmp);
573
#if defined (ECONNRESET)
575
throw EconnresetExc (tmp);
578
#if defined (ENOBUFS)
580
throw EnobufsExc (tmp);
583
#if defined (EISCONN)
585
throw EisconnExc (tmp);
588
#if defined (ENOTCONN)
590
throw EnotconnExc (tmp);
593
#if defined (ESHUTDOWN)
595
throw EshutdownExc (tmp);
598
#if defined (ETOOMANYREFS)
600
throw EtoomanyrefsExc (tmp);
603
#if defined (ETIMEDOUT)
605
throw EtimedoutExc (tmp);
608
#if defined (ECONNREFUSED)
610
throw EconnrefusedExc (tmp);
613
#if defined (EHOSTDOWN)
615
throw EhostdownExc (tmp);
618
#if defined (EHOSTUNREACH)
620
throw EhostunreachExc (tmp);
623
#if defined (EALREADY)
625
throw EalreadyExc (tmp);
628
#if defined (EINPROGRESS)
630
throw EinprogressExc (tmp);
635
throw EstaleExc (tmp);
638
#if defined (EIORESID)
640
throw EioresidExc (tmp);
643
#if defined (EUCLEAN)
645
throw EucleanExc (tmp);
648
#if defined (ENOTNAM)
650
throw EnotnamExc (tmp);
653
#if defined (ENAVAIL)
655
throw EnavailExc (tmp);
660
throw EisnamExc (tmp);
663
#if defined (EREMOTEIO)
665
throw EremoteioExc (tmp);
670
throw EinitExc (tmp);
673
#if defined (EREMDEV)
675
throw EremdevExc (tmp);
678
#if defined (ECANCELED)
680
throw EcanceledExc (tmp);
683
#if defined (ENOLIMFILE)
685
throw EnolimfileExc (tmp);
688
#if defined (EPROCLIM)
690
throw EproclimExc (tmp);
693
#if defined (EDISJOINT)
695
throw EdisjointExc (tmp);
698
#if defined (ENOLOGIN)
700
throw EnologinExc (tmp);
703
#if defined (ELOGINLIM)
705
throw EloginlimExc (tmp);
708
#if defined (EGROUPLOOP)
710
throw EgrouploopExc (tmp);
713
#if defined (ENOATTACH)
715
throw EnoattachExc (tmp);
718
#if defined (ENOTSUP) && defined (EOPNOTSUPP)
719
#if ENOTSUP != EOPNOTSUPP
721
throw EnotsupExc (tmp);
723
#elif defined (ENOTSUP)
725
throw EnotsupExc (tmp);
728
#if defined (ENOATTR)
730
throw EnoattrExc (tmp);
733
#if defined (EDIRCORRUPTED)
735
throw EdircorruptedExc (tmp);
740
throw EdquotExc (tmp);
743
#if defined (ENFSREMOTE)
745
throw EnfsremoteExc (tmp);
748
#if defined (ECONTROLLER)
750
throw EcontrollerExc (tmp);
753
#if defined (ENOTCONTROLLER)
755
throw EnotcontrollerExc (tmp);
758
#if defined (EENQUEUED)
760
throw EenqueuedExc (tmp);
763
#if defined (ENOTENQUEUED)
765
throw EnotenqueuedExc (tmp);
768
#if defined (EJOINED)
770
throw EjoinedExc (tmp);
773
#if defined (ENOTJOINED)
775
throw EnotjoinedExc (tmp);
778
#if defined (ENOPROC)
780
throw EnoprocExc (tmp);
783
#if defined (EMUSTRUN)
785
throw EmustrunExc (tmp);
788
#if defined (ENOTSTOPPED)
790
throw EnotstoppedExc (tmp);
793
#if defined (ECLOCKCPU)
795
throw EclockcpuExc (tmp);
798
#if defined (EINVALSTATE)
800
throw EinvalstateExc (tmp);
803
#if defined (ENOEXIST)
805
throw EnoexistExc (tmp);
808
#if defined (EENDOFMINOR)
810
throw EendofminorExc (tmp);
813
#if defined (EBUFSIZE)
815
throw EbufsizeExc (tmp);
820
throw EemptyExc (tmp);
823
#if defined (ENOINTRGROUP)
825
throw EnointrgroupExc (tmp);
828
#if defined (EINVALMODE)
830
throw EinvalmodeExc (tmp);
833
#if defined (ECANTEXTENT)
835
throw EcantextentExc (tmp);
838
#if defined (EINVALTIME)
840
throw EinvaltimeExc (tmp);
843
#if defined (EDESTROYED)
845
throw EdestroyedExc (tmp);
849
throw ErrnoExc (tmp);
853
void throwErrnoExc (const std::string &text)
855
throwErrnoExc (text, errno);