00001 // Author Antonio Bulgheroni, <mailto:antonio.bulgheroni@gmail.com> 00002 // Copyright 2009 Antonio Bulgheroni 00003 00004 // $Rev:: 7 $: Revision of the last commit 00005 // $Author:: drhilbert $: Author of the last commit 00006 // $Date:: 2009-08-27 00:08:23 +0200 (Thu, 27 Aug 2009) $: Date of the last commit 00007 00008 // This file is part of Mimotera++. 00009 // 00010 // Mimotera++ is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // Mimotera++ is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with Mimotera++. If not, see <http://www.gnu.org/licenses/>. 00022 00023 #include "mimotera++/MimoteraException.hh" 00024 #include "mimotera++/MimoteraUtils.hh" 00025 00026 namespace Mimotera { 00027 00028 MimoteraException::MimoteraException(const std::string & msg) 00029 : m_msg(msg), m_line(0) 00030 {} 00031 00032 const MimoteraException & MimoteraException::setLocation(const std::string & file, 00033 unsigned line, 00034 const std::string & func) const { 00035 m_file = file; 00036 m_line = line; 00037 m_func = func; 00038 return *this; 00039 } 00040 00041 void MimoteraException::make_text() const { 00042 m_text = m_msg; 00043 if (m_file.length() > 0) { 00044 m_text += "\n From " + m_file; 00045 if (m_line > 0) { 00046 m_text += ":" + to_string(m_line); 00047 } 00048 } 00049 if (m_func.length() > 0) m_text += "\n In " + m_func; 00050 } 00051 00052 }