swift
statusexception.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
4 #include "misc/statusexception.h"
5 
6 #include <QReadLocker>
7 #include <QWriteLocker>
8 
9 namespace swift::misc
10 {
11  CStatusException::CStatusException(const CStatusMessage &payload) : m_payload(payload) {}
12 
14  : std::exception(other), m_payload(other.m_payload)
15  {
16  QReadLocker lock(&other.m_lock);
17  this->m_temp = other.m_temp;
18  }
19 
20  const char *CStatusException::what() const noexcept
21  {
22  QWriteLocker lock(&this->m_lock);
23  if (m_temp.isNull()) { m_temp = m_payload.getMessage().toLocal8Bit(); }
24  return m_temp;
25  }
26 
28  {
29  if (!message.isEmpty()) { throw CStatusException(message); }
30  }
31 } // namespace swift::misc
bool isEmpty() const
Message empty.
Throwable exception class containing a CStatusMessage.
CStatusException(const CStatusMessage &payload)
Constructor.
static void maybeThrow(const CStatusMessage &)
If the message is not empty then throw it.
virtual const char * what() const noexcept
Return null-terminated message string.
Streamable status message, e.g.
QString getMessage() const
Message.
Free functions in swift::misc.