Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
berryCoreException.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "berryCoreException.h"
14 
15 #include "berryIStatus.h"
16 
17 namespace berry {
18 
20  : ctkException(status->GetMessage()), status(status)
21 {
22  if (status->GetException())
23  {
24  this->setCause(*status->GetException());
25  }
26 }
27 
29 {
30 }
31 
32 const char* CoreException::name() const throw()
33 {
34  return "Core exception";
35 }
36 
38 {
39  return new CoreException(*this);
40 }
41 
43 {
44  throw *this;
45 }
46 
48 {
49  return status;
50 }
51 
52 QDebug CoreException::printStackTrace(QDebug dbg) const
53 {
54  return PrintChildren(status.GetPointer(), ctkException::printStackTrace(dbg));
55 }
56 
57 QDebug CoreException::PrintChildren(IStatus *status, QDebug dbg) const
58 {
59  QList<IStatus::Pointer> children = status->GetChildren();
60  for (int i = 0; i < children.size(); ++i)
61  {
62  dbg << "Contains: " << qPrintable(children[i]->GetMessage()) << '\n';
63  const ctkException* exc = children[i]->GetException();
64  if (exc != nullptr)
65  {
66  dbg << exc->printStackTrace();
67  }
68  PrintChildren(children[i].GetPointer(), dbg);
69  }
70  return dbg;
71 }
72 
73 }
CoreException(const SmartPointer< IStatus > &status)
Implements transparent reference counting.
const char * name() const override
SmartPointer< IStatus > GetStatus() const
void rethrow() const override
virtual QList< IStatus::Pointer > GetChildren() const =0
CoreException * clone() const override