10 #ifndef _STRUS_LOCAL_ERROR_BUFFER_HPP_INCLUDED
11 #define _STRUS_LOCAL_ERROR_BUFFER_HPP_INCLUDED
38 throw std::logic_error(
"not implemented");
43 throw std::logic_error(
"not implemented");
46 virtual void report(
int errorcode,
const char* format, ...)
49 va_start( ap, format);
50 std::size_t hdrlen = 0;
53 hdrlen = std::snprintf( m_buf,
sizeof(m_buf),
"##%d ", errorcode);
55 std::vsnprintf( m_buf + hdrlen,
sizeof(m_buf) - hdrlen, format, ap);
56 m_buf[
sizeof(m_buf)-1] = 0;
58 m_errorCode = errorcode;
63 char tmpbuf[ BufferSize];
64 std::size_t len = std::snprintf( tmpbuf,
sizeof(tmpbuf), format, m_buf);
65 if (len >=
sizeof(tmpbuf))
67 len =
sizeof(tmpbuf)-1;
70 std::memcpy( m_buf, tmpbuf, len);
86 return m_errorCode >= 0;
91 throw std::logic_error(
"not implemented");
96 throw std::logic_error(
"not implemented");
110 enum {BufferSize=2048};
111 mutable char m_buf[ BufferSize];
LocalErrorBuffer()
Definition: localErrorBuffer.hpp:28
virtual bool setMaxNofThreads(unsigned int)
Redefine the maximum number of threads using the error buffer.
Definition: localErrorBuffer.hpp:41
virtual void report(int errorcode, const char *format,...)
Report an error.
Definition: localErrorBuffer.hpp:46
virtual void explain(const char *format)
Report an error, overwriting the previous error.
Definition: localErrorBuffer.hpp:61
virtual DebugTraceInterface * debugTrace() const
Fetches the debug trace interface if defined.
Definition: localErrorBuffer.hpp:99
virtual void setLogFile(FILE *)
Define error log file.
Definition: localErrorBuffer.hpp:36
virtual void releaseContext()
Dellocate context for current thread.
Definition: localErrorBuffer.hpp:94
Managing interface for reporting debug trace messages in a uniform way.
Definition: debugTraceInterface.hpp:81
virtual void allocContext()
Allocate context for current thread.
Definition: localErrorBuffer.hpp:89
Interface for reporting and catching errors in modules.
Definition: errorBufferInterface.hpp:24
Error buffer implementation for a context transforming the error message into an exceptions at the en...
Definition: localErrorBuffer.hpp:25
virtual const char * fetchError()
Check, if an error has occurred and return it.
Definition: localErrorBuffer.hpp:74
int errorCode() const
Definition: localErrorBuffer.hpp:104
Structured error codes for strus components.
virtual bool hasError() const
Check, if an error has occurred.
Definition: localErrorBuffer.hpp:84
Interface for reporting and catching errors.
virtual ~LocalErrorBuffer()
Definition: localErrorBuffer.hpp:34