Skip to content

Commit

Permalink
COMMON: Add copy-constructor for std::exception to StackException
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Mar 20, 2014
1 parent 7e754a8 commit b191282
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/common/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ StackException::StackException(const char *s, ...) {
StackException::StackException(const StackException &e) : _stack(e._stack) {
}

StackException::StackException(const std::exception &e) {
add(e);
}

StackException::~StackException() throw() {
}

Expand All @@ -66,6 +70,10 @@ void StackException::add(const char *s, ...) {
_stack.push(buf);
}

void StackException::add(const std::exception &e) {
add("%s", e.what());
}

const char *StackException::what() const throw() {
if (_stack.empty())
return "";
Expand Down
2 changes: 2 additions & 0 deletions src/common/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ class StackException : public std::exception {
StackException();
StackException(const char *s, ...);
StackException(const StackException &e);
StackException(const std::exception &e);
~StackException() throw();

void add(const char *s, ...);
void add(const std::exception &e);

const char *what() const throw();

Expand Down

0 comments on commit b191282

Please sign in to comment.