https://mooseframework.inl.gov
MooseBaseErrorInterface.h
Go to the documentation of this file.
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 #pragma once
11 
12 #include <sstream>
13 #include "ConsoleStreamInterface.h"
14 #include "MooseError.h"
15 #include "MooseBase.h"
16 
21 {
22 public:
23  MooseBaseErrorInterface(const MooseBase & base);
24 
28  template <typename... Args>
29  [[noreturn]] void mooseError(Args &&... args) const
30  {
31  std::ostringstream oss;
32  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
33  _moose_base.callMooseError(oss.str(), /* with_prefix = */ true);
34  }
35 
39  template <typename... Args>
40  [[noreturn]] void mooseErrorNonPrefixed(Args &&... args) const
41  {
42  std::ostringstream oss;
43  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
44  _moose_base.callMooseError(oss.str(), /* with_prefix = */ false);
45  }
46 
60  template <typename... Args>
61  [[noreturn]] void mooseDocumentedError(const std::string & repo_name,
62  const unsigned int issue_num,
63  Args &&... args) const
64  {
65  std::ostringstream oss;
66  moose::internal::mooseStreamAll(oss, std::forward<Args>(args)...);
67  const auto msg = moose::internal::formatMooseDocumentedError(repo_name, issue_num, oss.str());
68  _moose_base.callMooseError(msg, /* with_prefix = */ true);
69  }
70 
74  template <typename... Args>
75  void mooseWarning(Args &&... args) const
76  {
78  _console, _moose_base.errorPrefix("warning"), std::forward<Args>(args)...);
79  }
80 
84  template <typename... Args>
85  void mooseWarningNonPrefixed(Args &&... args) const
86  {
87  moose::internal::mooseWarningStream(_console, std::forward<Args>(args)...);
88  }
89 
90  template <typename... Args>
91  void mooseDeprecated(Args &&... args) const
92  {
94  _console, false, true, _moose_base.errorPrefix("deprecation"), std::forward<Args>(args)...);
95  }
96 
97  template <typename... Args>
98  void mooseInfo(Args &&... args) const
99  {
101  _console, _moose_base.errorPrefix("information"), std::forward<Args>(args)...);
102  }
103 
104 private:
107 };
void mooseStreamAll(std::ostringstream &ss)
All of the following are not meant to be called directly - they are called by the normal macros (moos...
Definition: MooseError.C:94
void mooseDeprecated(Args &&... args) const
Base class for everything in MOOSE with a name and a type.
Definition: MooseBase.h:32
void mooseErrorNonPrefixed(Args &&... args) const
Emits an error without the prefixing included in mooseError().
void mooseInfo(Args &&... args) const
Interface that provides APIs to output errors/warnings/info messages.
MooseBaseErrorInterface(const MooseBase &base)
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
void mooseInfoStream(S &oss, Args &&... args)
Definition: MooseError.h:232
void mooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
Emits a documented error with object name and type.
std::string errorPrefix(const std::string &error_type) const
Definition: MooseBase.C:43
An inteface for the _console for outputting to the Console object.
void mooseWarningStream(S &oss, Args &&... args)
Definition: MooseError.h:184
const MooseBase & _moose_base
The MooseBase class deriving from this interface.
void mooseDeprecatedStream(S &oss, const bool expired, const bool print_title, Args &&... args)
Definition: MooseError.h:239
void callMooseError(std::string msg, const bool with_prefix) const
Calls moose error with the message msg.
Definition: MooseBase.C:33
void mooseWarningNonPrefixed(Args &&... args) const
Emits a warning without the prefixing included in mooseWarning().
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
std::string formatMooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, const std::string &msg)
Formats a documented error.
Definition: MooseError.C:99