3 /// RAII class for OSyncError structs that are wholly
4 /// belonging to the barry plugin.
8 Copyright (C) 2009-2012, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #ifndef __BARRY_SYNC_TOSSERROR_H__
24 #define __BARRY_SYNC_TOSSERROR_H__
27 #include <opensync/opensync.h>
32 /// This is a wrapper class for OSyncError *error pointers.
33 /// For some of the opensync API, these error pointers are passed
34 /// into functions, such as osync_time_*() functions, and filled
35 /// in the event that an error occurs. These kinds of *errors are
36 /// not passed into the framework, and so it is our responsibility
39 /// This class makes it easy to do that freeing.
49 // simple wrapper... unref's the error on destruction
57 // log wrapper... logs to given tracer and unref's on destruction
58 TossError(const char *funcname
, Trace
&trace
)
70 /// Returns NULL if no error
71 const char* GetErrorMsg()
73 return osync_error_print(&m_error
);
78 return osync_error_is_set(&m_error
);
83 if( m_error
&& m_trace
)
84 m_trace
->logf("%s: %s", m_func
, GetErrorMsg());
91 osync_error_unref(&m_error
);
96 operator OSyncError
**()