Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "MooseBase.h" 11 : 12 : #include "MooseError.h" 13 : #include "InputParameters.h" 14 : #include "MooseApp.h" 15 : 16 : #include "hit/parse.h" 17 : 18 5276479 : MooseBase::MooseBase(const std::string & type, 19 : const std::string & name, 20 : MooseApp & app, 21 5276479 : const InputParameters & params) 22 5276479 : : _app(app), _type(type), _name(name), _params(params) 23 : { 24 5276479 : } 25 : 26 : std::string 27 58707 : MooseBase::typeAndName() const 28 : { 29 117414 : return type() + std::string(" \"") + name() + std::string("\""); 30 : } 31 : 32 : [[noreturn]] void 33 3025 : MooseBase::callMooseError(std::string msg, const bool with_prefix) const 34 : { 35 3025 : _app.getOutputWarehouse().mooseConsole(); 36 3025 : const std::string prefix = _app.isUltimateMaster() ? "" : _app.name(); 37 3025 : if (with_prefix) 38 1574 : msg = errorPrefix("error") + msg; 39 3091 : moose::internal::mooseErrorRaw(msg, prefix); 40 33 : } 41 : 42 : std::string 43 11816 : MooseBase::errorPrefix(const std::string & error_type) const 44 : { 45 11816 : std::stringstream oss; 46 11816 : if (const auto node = _params.getHitNode()) 47 11787 : if (!node->isRoot()) 48 8489 : oss << node->fileLocation() << ":\n"; 49 11816 : oss << "The following " << error_type << " occurred in the "; 50 11816 : if (const auto base_ptr = _params.getBase()) 51 11816 : oss << *base_ptr; 52 : else 53 11816 : oss << "object"; 54 11816 : oss << " '" << name() << "' of type " << type() << ".\n\n"; 55 23632 : return oss.str(); 56 11816 : }