HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IexThrowErrnoExc.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright (c) Contributors to the OpenEXR Project.
4 //
5 
6 
7 #ifndef INCLUDED_IEXTHROWERRNOEXC_H
8 #define INCLUDED_IEXTHROWERRNOEXC_H
9 
10 //----------------------------------------------------------
11 //
12 // A function which throws ExcErrno exceptions
13 //
14 //----------------------------------------------------------
15 
16 #include "IexBaseExc.h"
17 #include "IexExport.h"
18 
20 
21 
22 //--------------------------------------------------------------------------
23 //
24 // Function throwErrnoExc() throws an exception which corresponds to
25 // error code errnum. The exception text is initialized with a copy
26 // of the string passed to throwErrnoExc(), where all occurrences of
27 // "%T" have been replaced with the output of strerror(oserror()).
28 //
29 // Example:
30 //
31 // If opening file /tmp/output failed with an ENOENT error code,
32 // calling
33 //
34 // throwErrnoExc ();
35 //
36 // or
37 //
38 // throwErrnoExc ("%T.");
39 //
40 // will throw an EnoentExc whose text reads
41 //
42 // No such file or directory.
43 //
44 // More detailed messages can be assembled using stringstreams:
45 //
46 // std::stringstream s;
47 // s << "Cannot open file " << name << " (%T).";
48 // throwErrnoExc (s);
49 //
50 // The resulting exception contains the following text:
51 //
52 // Cannot open file /tmp/output (No such file or directory).
53 //
54 // Alternatively, you may want to use the THROW_ERRNO macro defined
55 // in IexMacros.h:
56 //
57 // THROW_ERRNO ("Cannot open file " << name << " (%T).")
58 //
59 //--------------------------------------------------------------------------
60 
61 IEX_EXPORT void throwErrnoExc(const std::string &txt, int errnum);
62 IEX_EXPORT void throwErrnoExc(const std::string &txt);
64 
66 
67 #endif // INCLUDED_IEXTHROWERRNOEXC_H
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define IEX_EXPORT
Definition: IexExport.h:30
IEX_INTERNAL_NAMESPACE_HEADER_ENTER IEX_EXPORT void throwErrnoExc(const std::string &txt, int errnum)
#define IEX_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: IexNamespace.h:77
#define IEX_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: IexNamespace.h:78