HIRS/HIRS_ProvisionerTPM2/src/HirsRuntimeException.cpp
2018-09-06 09:47:33 -04:00

32 lines
816 B
C++

/**
* Copyright (C) 2017-2018, U.S. Government
*/
#include <HirsRuntimeException.h>
#include <sstream>
#include <string>
using hirs::exception::HirsRuntimeException;
using std::endl;
using std::string;
using std::stringstream;
HirsRuntimeException::HirsRuntimeException(const string& msg,
const string& origin)
: runtime_error(buildMessage(msg, origin)) {}
HirsRuntimeException::~HirsRuntimeException() = default;
string HirsRuntimeException::buildMessage(const string& msg,
const string& origin) {
stringstream headerStream;
if (!origin.empty()) {
headerStream << "<" << origin << ">: ";
}
stringstream msgStream;
msgStream << headerStream.str() << msg << endl;
return msgStream.str();
}