PageRenderTime 24ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Rainman2/exception.cpp

http://modstudio2.googlecode.com/
C++ | 55 lines | 27 code | 4 blank | 24 comment | 1 complexity | 12e3cea6f99a2fae8e673f7c07467f22 MD5 | raw file
 1/*
 2Copyright (c) 2008 Peter "Corsix" Cawley
 3
 4Permission is hereby granted, free of charge, to any person
 5obtaining a copy of this software and associated documentation
 6files (the "Software"), to deal in the Software without
 7restriction, including without limitation the rights to use,
 8copy, modify, merge, publish, distribute, sublicense, and/or sell
 9copies of the Software, and to permit persons to whom the
10Software is furnished to do so, subject to the following
11conditions:
12
13The above copyright notice and this permission notice shall be
14included in all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23OTHER DEALINGS IN THE SOFTWARE.
24*/
25#include "exception.h"
26
27RainException::RainException(const RainString sFile, unsigned long iLine, const RainString sMessage, RainException* pPrevious)
28  : m_sFile(sFile), m_sMessage(sMessage), m_iLine(iLine), m_pPrevious(pPrevious)
29{
30}
31
32RainException::~RainException()
33{
34  delete m_pPrevious;
35}
36
37RainException::RainException(const RainString sFile, unsigned long iLine, RainException* pPrevious, const RainString sFormat, ...)
38  : m_sFile(sFile), m_iLine(iLine), m_pPrevious(pPrevious)
39{
40  va_list vArgs;
41  va_start(vArgs, sFormat);
42  m_sMessage.printfV(sFormat, vArgs);
43  va_end(vArgs);
44}
45
46void RainException::checkAssert(const RainChar* sFile, unsigned long iLine, bool bAssertion, const RainChar* sCheck) throw(...)
47{
48  if(!bAssertion)
49  {
50    RainString sFile(sFile);
51    RainString sMessage(L"Assertion failed: ");
52    sMessage += sCheck;
53    throw new RainException(RainString(sFile), iLine, sMessage);
54  }
55}