TrueReality  v0.1.1912
Exception.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * The Base of this class has been adopted from the Delta3D engine
6 *
7 * This library is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 3.0 of the License, or (at your option)
10 * any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Class Inspired by the Delta3D Engine
22 * http://delta3dengine.org/
23 *
24 * @author Matthew W. Campbell
25 * @author Maxim Serebrennik
26 */
27 #pragma once
28 
29 #include <trUtil/Export.h>
30 
31 #include <trUtil/Logging/Log.h>
32 
33 #include <string>
34 
40 namespace trUtil
41 {
49  {
50  public:
51 
61  Exception(const std::string& message, const std::string& filename, unsigned int linenum);
62 
68  virtual ~Exception();
69 
77  const std::string& What() const;
78 
86  const std::string& File() const;
87 
95  unsigned int Line() const;
96 
105  std::string ToString() const;
106 
112  void Print() const;
113 
121  void LogException(trUtil::Logging::LogLevel level = trUtil::Logging::LogLevel::LOG_ERROR) const;
122 
131  void LogException(trUtil::Logging::LogLevel level, const std::string& loggerName) const;
132 
141  void LogException(trUtil::Logging::LogLevel level, trUtil::Logging::Log& logger) const;
142 
143  private:
144  std::string mMessage, mFileName;
145  unsigned int mLineNum;
146  };
147 
158  TR_UTIL_EXPORT std::ostream& operator << (std::ostream& o, const Exception& ex);
159 }
Log class which the engine uses for all of its logging needs.
Definition: Log.h:197
This is the exception class used throughout the engine.
Definition: Exception.h:48
unsigned int mLineNum
Definition: Exception.h:145
std::string ToString(const T &t, int precision=-1)
A utility function to convert a basic type into a string.
Definition: StringUtils.h:334
TR_UTIL_EXPORT std::ostream & operator<<(std::ostream &os, const EnumerationString &e)
Helper method to print EnumerationNumeric to an output stream.
std::string mMessage
Definition: Exception.h:144
A class that represents date time utility.
Namespace that holds various utility classes for the engine.
Definition: SmrtPtr.h:208
LOG_ERROR
Definition: LogLevel.h:64