Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
berryCoreException.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "berryCoreException.h"
18 
19 #include "berryIStatus.h"
20 
21 namespace berry {
22 
24  : ctkException(status->GetMessage()), status(status)
25 {
26  if (status->GetException())
27  {
28  this->setCause(*status->GetException());
29  }
30 }
31 
33 {
34 }
35 
36 const char* CoreException::name() const throw()
37 {
38  return "Core exception";
39 }
40 
42 {
43  return new CoreException(*this);
44 }
45 
47 {
48  throw *this;
49 }
50 
52 {
53  return status;
54 }
55 
56 QDebug CoreException::printStackTrace(QDebug dbg) const
57 {
58  return PrintChildren(status.GetPointer(), ctkException::printStackTrace(dbg));
59 }
60 
61 QDebug CoreException::PrintChildren(IStatus *status, QDebug dbg) const
62 {
63  QList<IStatus::Pointer> children = status->GetChildren();
64  for (int i = 0; i < children.size(); ++i)
65  {
66  dbg << "Contains: " << qPrintable(children[i]->GetMessage()) << '\n';
67  const ctkException* exc = children[i]->GetException();
68  if (exc != nullptr)
69  {
70  dbg << exc->printStackTrace();
71  }
72  PrintChildren(children[i].GetPointer(), dbg);
73  }
74  return dbg;
75 }
76 
77 }
CoreException(const SmartPointer< IStatus > &status)
Implements transparent reference counting.
const char * name() const override
SmartPointer< IStatus > GetStatus() const
void rethrow() const override
CoreException * clone() const override