1 /** 2 * @file error.cpp 3 * Exceptions. @ingroup errors 4 * 5 * @authors Copyright © 2009-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 6 * 7 * @par License 8 * LGPL: http://www.gnu.org/licenses/lgpl.html 9 * 10 * <small>This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as published by 12 * the Free Software Foundation; either version 3 of the License, or (at your 13 * option) any later version. This program is distributed in the hope that it 14 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 16 * General Public License for more details. You should have received a copy of 17 * the GNU Lesser General Public License along with this program; if not, see: 18 * http://www.gnu.org/licenses</small> 19 */ 20 21 #include "de/error.h" 22 #include "core/logtextstyle.h" 23 24 namespace de { 25 Error(QString const & where,QString const & message)26Error::Error(QString const &where, QString const &message) 27 : std::runtime_error(QString("%1(in " _E(m) "%2" _E(.) ")" _E(.) " %3") 28 .arg(TEXT_STYLE_SECTION) 29 .arg(where) 30 .arg(message) 31 .toStdString()) 32 , _name("") 33 {} 34 name() const35QString Error::name() const 36 { 37 if (!_name.size()) return "Error"; 38 return QString::fromStdString(_name); 39 } 40 asText() const41QString Error::asText() const 42 { 43 return QString("%1[%2]" _E(.) " %4") 44 .arg(TEXT_STYLE_SECTION) 45 .arg(name()) 46 .arg(std::runtime_error::what()); 47 } 48 setName(QString const & name)49void Error::setName(QString const &name) 50 { 51 if (_name.size()) _name += "_"; 52 _name += name.toStdString(); 53 } 54 55 } // namespace de 56