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 5723931 : MooseBase::MooseBase(const std::string & type, 19 : const std::string & name, 20 : MooseApp & app, 21 5723931 : const InputParameters & params) 22 5723931 : : _app(app), _type(type), _name(name), _params(params) 23 : { 24 5723931 : } 25 : 26 : std::string 27 62525 : MooseBase::typeAndName() const 28 : { 29 125050 : return type() + std::string(" \"") + name() + std::string("\""); 30 : } 31 : 32 : [[noreturn]] void 33 3057 : MooseBase::callMooseError(std::string msg, const bool with_prefix) const 34 : { 35 3057 : _app.getOutputWarehouse().mooseConsole(); 36 3057 : const std::string prefix = _app.isUltimateMaster() ? "" : _app.name(); 37 3057 : if (with_prefix) 38 1602 : msg = errorPrefix("error") + msg; 39 3123 : moose::internal::mooseErrorRaw(msg, prefix); 40 33 : } 41 : 42 : std::string 43 16755 : MooseBase::errorPrefix(const std::string & error_type) const 44 : { 45 16755 : std::stringstream oss; 46 16755 : if (const auto node = _params.getHitNode()) 47 16726 : if (!node->isRoot()) 48 13424 : oss << node->fileLocation() << ":\n"; 49 16755 : oss << "The following " << error_type << " occurred in the "; 50 16755 : if (const auto base_ptr = _params.getBase()) 51 16755 : oss << *base_ptr; 52 : else 53 16755 : oss << "object"; 54 16755 : oss << " '" << name() << "' of type " << type() << ".\n\n"; 55 33510 : return oss.str(); 56 16755 : }