Audacity  3.0.3
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 (InconsistencyException &&that)
 
 ~InconsistencyException () override
 
unsigned GetLine () const
 
- Public Member Functions inherited from AudacityException
 AudacityException ()
 
virtual ~AudacityException ()=0
 

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 wxString ErrorHelpUrl () const
 
- Protected Member Functions inherited from AudacityException
 AudacityException (const AudacityException &)=default
 Make this protected to prevent slicing copies. More...
 
 AudacityException (AudacityException &&) PROHIBITED
 Don't allow moves of this class or subclasses. More...
 
AudacityExceptionoperator= (const AudacityException &) PROHIBITED
 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  {}

References Internal, and XO.

◆ 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  {}

References Internal, and XO.

◆ InconsistencyException() [3/3]

InconsistencyException::InconsistencyException ( InconsistencyException &&  that)
inline

Definition at line 40 of file InconsistencyException.h.

41  : MessageBoxException(std::move(that))
42  , func{ that.func }
43  , file{ that.file }
44  , line{ that.line }
45  {}

◆ ~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
28 XO("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
32 XO("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.

◆ 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:
fn
static const auto fn
Definition: WaveformView.cpp:1108
InconsistencyException::file
const char * file
Definition: InconsistencyException.h:56
XO
#define XO(s)
Definition: Internat.h:31
InconsistencyException::func
const char * func
Definition: InconsistencyException.h:55
MessageBoxException
Abstract AudacityException subclass displays a message, specified by further subclass.
Definition: AudacityException.h:62
InconsistencyException::line
unsigned line
Definition: InconsistencyException.h:57
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
MessageBoxException::MessageBoxException
MessageBoxException(ExceptionType exceptionType, const TranslatableString &caption)
If default-constructed with empty caption, it makes no message box.
Definition: AudacityException.cpp:39