1#ifndef __AUDACITY_EXCEPTION__
2#define __AUDACITY_EXCEPTION__
41 static void EnqueueAction(
42 std::exception_ptr pException,
67 void DelayedHandlerAction()
final;
87 mutable bool moved {
false };
89 mutable wxString helpUrl{
"" };
101 const wxString &helpUrl_ =
""
104 , message{ message_ }
136 noexcept(
noexcept( R{ std::declval<const R&>() } ))
139 noexcept(
noexcept( R{ std::declval<R>() } ))
166template <
typename R >
209 const F2 &
handler = F2::Default(),
214 noexcept(
handler( std::declval<AudacityException*>() ) ) &&
215 noexcept(
handler(
nullptr ) ) &&
219 try {
return body(); }
221 #ifndef UNCAUGHT_EXCEPTIONS_UNAVAILABLE
222 const auto uncaughtExceptionsCount = std::uncaught_exceptions();
224 auto end =
finally( [&]()
227 std::move(delayedHandler)} )) {
231 #ifdef UNCAUGHT_EXCEPTIONS_UNAVAILABLE
232 if (!std::uncaught_exception()) {
234 if (uncaughtExceptionsCount >= std::uncaught_exceptions()) {
236 auto pException = std::current_exception();
238 pException, std::move(delayedHandler));
ExceptionType
A type of an exception.
@ BadEnvironment
Indicates problems with environment, such as a full disk.
@ BadUserAction
Indicates that the user performed an action that is not allowed.
@ Internal
Indicates internal failure from Audacity.
SimpleGuard< R > MakeSimpleGuard(R value) noexcept(noexcept(SimpleGuard< R >{ value }))
Convert a value to a handler function returning that value, suitable for GuardedCall<R>
void DefaultDelayedHandlerAction(AudacityException *pException)
A default template parameter for GuardedCall.
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
Base class for exceptions specially processed by the application.
virtual void DelayedHandlerAction()=0
Action to do in the main thread at idle time of the event loop.
static void EnqueueAction(std::exception_ptr pException, std::function< void(AudacityException *)> delayedHandler)
AudacityException(AudacityException &&)=delete
Don't allow moves of this class or subclasses.
AudacityException(const AudacityException &)=default
Make this protected to prevent slicing copies.
Abstract AudacityException subclass displays a message, specified by further subclass.
virtual TranslatableString ErrorMessage() const =0
Format the error message for this exception.
virtual wxString ErrorHelpUrl() const
TranslatableString caption
Stored caption.
ExceptionType exceptionType
Exception type.
A MessageBoxException that shows a given, unvarying string.
SimpleMessageBoxException(const SimpleMessageBoxException &)=default
TranslatableString message
Stored message.
SimpleMessageBoxException(ExceptionType exceptionType, const TranslatableString &message_, const TranslatableString &caption=XO("Message"), const wxString &helpUrl_="")
Holds a msgid for the translation catalog; may also bind format arguments.
AuthorizationHandler handler
const char * end(const char *str) noexcept
static SimpleGuard Default() noexcept
SimpleGuard(bool value) noexcept
Specialization of SimpleGuard, also defining a default value.
static SimpleGuard Default() noexcept
A default template parameter for GuardedCall<R>
SimpleGuard(const R &value) noexcept(noexcept(R{ std::declval< const R & >() }))
R operator()(AudacityException *) const noexcept(noexcept(R{ std::declval< R >() }))