]> www.ginac.de Git - cln.git/blob - src/base/cl_as_exception.cc
Use paths relative the `src' directory in the #include directives.
[cln.git] / src / base / cl_as_exception.cc
1 // as_exception().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/exception.h"
8
9
10 // Implementation.
11
12 #include "cln/io.h"
13 #include "base/cl_N.h"
14 #include <sstream>
15
16 namespace cln {
17
18 static inline const std::string
19 as_error_msg (const cl_number& obj, const char * typestring, const char * filename, int line)
20 {
21         std::ostringstream buf;
22         fprint(buf, "Type assertion failed: in file ");
23         fprint(buf, filename);
24         fprint(buf, ", line ");
25         fprintdecimal(buf, line);
26         fprint(buf, ", not ");
27         fprint(buf, typestring);
28         fprint(buf, ": ");
29 #if 0 // This brings in a dependency from the complex and float printer and all the float stuff.
30         fprint(buf, obj);
31 #else
32         fprint(buf, "@0x");
33         fprinthexadecimal(buf, (unsigned long)(void*)&obj);
34         fprint(buf, ": 0x");
35         fprinthexadecimal(buf, (unsigned long)obj.word);
36 #endif
37         return buf.str();
38 }
39
40 as_exception::as_exception (const cl_number& obj, const char * typestring, const char * filename, int line)
41         : runtime_exception(as_error_msg(obj, typestring, filename, line))
42 {}
43
44 }  // namespace cln