Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
UserException Class Referencefinal

Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing. More...

#include <UserException.h>

Inheritance diagram for UserException:
[legend]
Collaboration diagram for UserException:
[legend]

Public Types

using ProgressReporter = std::function< void(double)>
 

Public Member Functions

 UserException ()
 
 ~UserException () override
 
void DelayedHandlerAction () override
 Action to do in the main thread at idle time of the event loop. More...
 
- Public Member Functions inherited from AudacityException
 AudacityException ()
 
virtual ~AudacityException ()=0
 
virtual void DelayedHandlerAction ()=0
 Action to do in the main thread at idle time of the event loop. More...
 

Static Public Member Functions

static void WithCancellableProgress (std::function< void(const ProgressReporter &)> action, TranslatableString title, TranslatableString message)
 A frequently useful convenience wraps a lambda and may throw this type. More...
 
- Static Public Member Functions inherited from AudacityException
static void EnqueueAction (std::exception_ptr pException, std::function< void(AudacityException *)> delayedHandler)
 

Additional Inherited Members

- Protected Member Functions inherited from AudacityException
 AudacityException (const AudacityException &)=default
 Make this protected to prevent slicing copies. More...
 
 AudacityException (AudacityException &&)=delete
 Don't allow moves of this class or subclasses. More...
 
AudacityExceptionoperator= (const AudacityException &)=delete
 Disallow assignment. More...
 

Detailed Description

Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.

This class does not inherit from MessageBoxException.

Definition at line 16 of file UserException.h.

Member Typedef Documentation

◆ ProgressReporter

using UserException::ProgressReporter = std::function<void(double)>

Definition at line 25 of file UserException.h.

Constructor & Destructor Documentation

◆ UserException()

UserException::UserException ( )
inline

Definition at line 19 of file UserException.h.

19{}

◆ ~UserException()

UserException::~UserException ( )
override

Definition at line 12 of file UserException.cpp.

13{
14}

Member Function Documentation

◆ DelayedHandlerAction()

void UserException::DelayedHandlerAction ( )
overridevirtual

Action to do in the main thread at idle time of the event loop.

Implements AudacityException.

Definition at line 16 of file UserException.cpp.

17{
18}

◆ WithCancellableProgress()

void UserException::WithCancellableProgress ( std::function< void(const ProgressReporter &)>  action,
TranslatableString  title,
TranslatableString  message 
)
static

A frequently useful convenience wraps a lambda and may throw this type.

Definition at line 20 of file UserException.cpp.

23{
24 using namespace BasicUI;
25 auto progress =
26 MakeProgress(std::move(title), std::move(message), ProgressShowCancel);
27 const auto reportProgress = [&](double progressFraction) {
28 const auto result = progress->Poll(progressFraction * 1000, 1000);
29 if (result != ProgressResult::Success)
30 throw UserException {};
31 };
32 action(reportProgress);
33}
static const auto title
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
@ ProgressShowCancel
Definition: BasicUI.h:142
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:294

References BasicUI::MakeProgress(), BasicUI::ProgressShowCancel, BasicUI::Success, and title.

Referenced by EffectAutoDuck::Process(), and TimeStretching::WithClipRenderingProgress().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: