Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
InconsistencyException Class Referencefinal

Exception that should be impossible in production, thrown only from provably unreachable places. More...

#include <InconsistencyException.h>

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

Public Member Functions

 InconsistencyException ()
 
 InconsistencyException (const char *fn, const char *f, unsigned l)
 Don't call this directly but use CONSTRUCT_INCONSISTENCY_EXCEPTION or THROW_INCONSISTENCY_EXCEPTION. More...
 
 InconsistencyException (const InconsistencyException &that)
 
 ~InconsistencyException () override
 
unsigned GetLine () const
 
- 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...
 

Private Member Functions

TranslatableString ErrorMessage () const override
 Format the error message for this exception. More...
 

Private Attributes

const char * func {}
 
const char * file {}
 
unsigned line {}
 

Additional Inherited Members

- Static Public Member Functions inherited from AudacityException
static void EnqueueAction (std::exception_ptr pException, std::function< void(AudacityException *)> delayedHandler)
 
- Protected Member Functions inherited from MessageBoxException
 MessageBoxException (ExceptionType exceptionType, const TranslatableString &caption)
 If default-constructed with empty caption, it makes no message box. More...
 
 ~MessageBoxException () override
 
 MessageBoxException (const MessageBoxException &)
 
virtual TranslatableString ErrorMessage () const =0
 Format the error message for this exception. More...
 
virtual wxString ErrorHelpUrl () const
 
- 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...
 
- Protected Attributes inherited from MessageBoxException
wxString helpUrl { "" }
 

Detailed Description

Exception that should be impossible in production, thrown only from provably unreachable places.

Some errors that formerly were assertion violations now throw exceptions, even in production code. These may be violations of function preconditions or the results of logical errors internal to functions. These conditions are supposed to be deducible statically as never happening.

The error message identifies source file and line number, possibly the function too (depending on the compiler), and suggests that the user inform the development team.

Definition at line 23 of file InconsistencyException.h.

Constructor & Destructor Documentation

◆ InconsistencyException() [1/3]

InconsistencyException::InconsistencyException ( )
inline

Definition at line 26 of file InconsistencyException.h.

27 : MessageBoxException{ ExceptionType::Internal, XO ("Internal Error") }
28 {}
@ Internal
Indicates internal failure from Audacity.
XO("Cut/Copy/Paste")
Abstract AudacityException subclass displays a message, specified by further subclass.

◆ InconsistencyException() [2/3]

InconsistencyException::InconsistencyException ( const char *  fn,
const char *  f,
unsigned  l 
)
inlineexplicit

Don't call this directly but use CONSTRUCT_INCONSISTENCY_EXCEPTION or THROW_INCONSISTENCY_EXCEPTION.

Parameters
fnfile name supplied by preprocessor
ffunction name supplied by preprocessor
lline number supplied by preprocessor

Definition at line 31 of file InconsistencyException.h.

36 : MessageBoxException { ExceptionType::Internal, XO("Internal Error") }
37 , func { fn }, file { f }, line { l }
38 {}
static const auto fn

◆ InconsistencyException() [3/3]

InconsistencyException::InconsistencyException ( const InconsistencyException that)
inline

Definition at line 40 of file InconsistencyException.h.

42 , func{ that.func }
43 , file{ that.file }
44 , line{ that.line }
45 {}
MessageBoxException(ExceptionType exceptionType, const TranslatableString &caption)
If default-constructed with empty caption, it makes no message box.

◆ ~InconsistencyException()

InconsistencyException::~InconsistencyException ( )
override

Definition at line 13 of file InconsistencyException.cpp.

14{
15}

Member Function Documentation

◆ ErrorMessage()

TranslatableString InconsistencyException::ErrorMessage ( ) const
overrideprivatevirtual

Format the error message for this exception.

Implements MessageBoxException.

Definition at line 17 of file InconsistencyException.cpp.

18{
19 // Shorten the path
20 wxString path { file };
21 auto sub = wxString{ wxFILE_SEP_PATH } + "src" + wxFILE_SEP_PATH;
22 auto index = path.Find(sub);
23 if (index != wxNOT_FOUND)
24 path = path.Mid(index + sub.size());
25
26#ifdef __func__
27 return
28XO("Internal error in %s at %s line %d.\nPlease inform the Audacity team at https://forum.audacityteam.org/.")
29 .Format( func, path, line );
30#else
31 return
32XO("Internal error at %s line %d.\nPlease inform the Audacity team at https://forum.audacityteam.org/.")
33 .Format( path, line );
34#endif
35}

References file, func, line, and XO().

Here is the call graph for this function:

◆ GetLine()

unsigned InconsistencyException::GetLine ( ) const
inline

Definition at line 49 of file InconsistencyException.h.

49{ return line; }

Member Data Documentation

◆ file

const char* InconsistencyException::file {}
private

Definition at line 56 of file InconsistencyException.h.

Referenced by ErrorMessage().

◆ func

const char* InconsistencyException::func {}
private

Definition at line 55 of file InconsistencyException.h.

Referenced by ErrorMessage().

◆ line

unsigned InconsistencyException::line {}
private

Definition at line 57 of file InconsistencyException.h.

Referenced by ErrorMessage().


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