载入中...
搜索中...
未找到
Exception.cpp
浏览该文件的文档.
1
2
3#include "Exception.h"
5
6#include <iostream>
7#include <cstdlib>
8#include <cstdarg>
9#include <cstring>
10
11namespace eve
12{
13
14Exception::Exception(const char *fmt, ...)
15{
16 va_list args;
17 int size_buffer = 256, size_out;
18 char *buffer;
19 while (true)
20 {
21 buffer = new char[size_buffer];
22 memset(buffer, 0, size_buffer);
23
24 va_start(args, fmt);
25 size_out = vsnprintf(buffer, size_buffer, fmt, args);
26 va_end(args);
27
28 // see http://perfec.to/vsnprintf/pasprintf.c
29 // if size_out ...
30 // == -1 --> output was truncated
31 // == size_buffer --> output was truncated
32 // == size_buffer-1 --> ambiguous, /may/ have been truncated
33 // > size_buffer --> output was truncated, and size_out
34 // bytes would have been written
35 if (size_out == size_buffer || size_out == -1 || size_out == size_buffer-1)
36 size_buffer *= 2;
37 else if (size_out > size_buffer)
38 size_buffer = size_out + 2; // to avoid the ambiguous case
39 else
40 break;
41
42 delete[] buffer;
43 }
44 message = std::string(buffer);
45 delete[] buffer;
46 // When DevTool/render tracer is active, mark the failure site for slicing.
47 eve::debug::rtError(message.c_str());
48}
49
51{
52}
53
54}
virtual ~Exception()
Definition Exception.cpp:50
Exception(const char *fmt,...)
Definition Exception.cpp:14
void rtError(const char *message)
Definition RenderTrace.h:51
Definition Build.cpp:11