Commit 565c7a37 authored by Eric Cano's avatar Eric Cano
Browse files

Fixed inheritance from std::exception (const correctness of what()). This...

Fixed inheritance from std::exception (const correctness of what()). This required declaring m_what mutable.
Created a multithreaded unit test.
Created an automatic exception thrower for unhandled errors.
Ported from previous proof of concept the threading primitves and made them production level (with error checking).
Added unit tests for threading primitives.
parent 07377235
......@@ -51,7 +51,7 @@ castor::exception::Backtrace::Backtrace(): m_trace() {
m_trace += before;
m_trace += demangled;
m_trace += after;
m_trace += "(C++ demangled)\n";
m_trace += "\n";
} else {
m_trace += strings[i];
m_trace += "\n";
......
......@@ -55,8 +55,8 @@ castor::exception::Exception& castor::exception::Exception::operator=(
//------------------------------------------------------------------------------
// what operator
//------------------------------------------------------------------------------
const char * castor::exception::Exception::what() {
m_what = getMessage().str();
const char * castor::exception::Exception::what() const throw () {
m_what = getMessageValue();
m_what += "\n";
m_what += (std::string) m_backtrace;
return m_what.c_str();
......
......@@ -96,7 +96,7 @@ namespace castor {
* the stack trace.
* @return pointer to m_what's contents
*/
virtual const char * what();
virtual const char * what() const throw ();
/**
* gets the serrno code of the corresponding C error
......@@ -116,7 +116,7 @@ namespace castor {
* Placeholder for the what result. It has to be a member
* of the object, and not on the stack of the "what" function.
*/
std::string m_what;
mutable std::string m_what;
protected:
/**
......
......@@ -36,12 +36,13 @@ set(CTEST_OUTPUT_ON_FAILURE 1)
# Add parts first in dependency order
add_subdirectory(SCSI)
add_subdirectory(Drive)
add_subdirectory(System)
add_subdirectory(Exception)
add_subdirectory(Utils)
add_subdirectory(File)
add_subdirectory(Daemon)
add_subdirectory(drive)
add_subdirectory(system)
add_subdirectory(exception)
add_subdirectory(utils)
add_subdirectory(file)
add_subdirectory(daemon)
add_subdirectory(threading)
# .. and of course, the tests (last to use the variable definition)
add_subdirectory(test)
......
......@@ -28,9 +28,9 @@
#include <regex.h>
#include <sys/types.h>
#include <dirent.h>
#include "../System/Wrapper.hpp"
#include "../Exception/Exception.hpp"
#include "../Utils/Regex.hpp"
#include "../system/Wrapper.hpp"
#include "../exception/Exception.hpp"
#include "../utils/Regex.hpp"
#include "Constants.hpp"
namespace castor {
......
......@@ -25,7 +25,7 @@
#include <gtest/gtest.h>
#include <gmock/gmock-cardinalities.h>
#include "Device.hpp"
#include "../System/Wrapper.hpp"
#include "../system/Wrapper.hpp"
using ::testing::AtLeast;
using ::testing::Return;
......
......@@ -22,7 +22,7 @@
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "../Exception/Exception.hpp"
#include "../exception/Exception.hpp"
#include "Structures.hpp"
#include "Constants.hpp"
......
......@@ -34,7 +34,7 @@
#include <cstdio>
#include "Constants.hpp"
#include "../Exception/Exception.hpp"
#include "../exception/Exception.hpp"
namespace castor {
namespace tape {
......
......@@ -26,7 +26,7 @@
#include <gmock/gmock-cardinalities.h>
#include "Device.hpp"
#include "Structures.hpp"
#include "../System/Wrapper.hpp"
#include "../system/Wrapper.hpp"
#include "Exception.hpp"
using ::testing::AtLeast;
......
......@@ -23,7 +23,7 @@
*****************************************************************************/
#pragma once
#include "../Exception/Exception.hpp"
#include "../exception/Exception.hpp"
namespace castor {
namespace tape {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment