Audacity  2.2.0
InconsistencyException.h
Go to the documentation of this file.
1 //
2 // InconsistencyException.h
3 //
4 //
5 // Created by Paul Licameli on 11/27/16.
6 //
7 // Some errors that formerly were assertion violations now throw exceptions,
8 // even in production code. These may be violations of function preconditions
9 // or the results of logical errors internal to functions. These conditions
10 // are supposed to be deducible statically as never happening.
11 //
12 
13 #ifndef __AUDACITY_INCONSISTENCY_EXCEPTION__
14 #define __AUDACITY_INCONSISTENCY_EXCEPTION__
15 
16 #include "AudacityException.h"
17 
19 {
20 public:
22 
23  explicit InconsistencyException
24  ( const char *fn, const char *f, unsigned l )
25  : MessageBoxException{ _("Internal Error") }
26  , func { fn }, file { f }, line { l }
27  {}
28 
30  : MessageBoxException(std::move(that))
31  , func{ that.func }
32  , file{ that.file }
33  , line{ that.line }
34  {}
36  {
37  if (this != &that) {
38  MessageBoxException::operator= (std::move(that));
39  func = that.func;
40  file = that.file;
41  line = that.line;
42  }
43  return *this;
44  }
45 
46  ~InconsistencyException() override;
47 
48  unsigned GetLine() const { return line; }
49 
50 private:
51  std::unique_ptr< AudacityException > Move() override;
52 
53  // Format a default, internationalized error message for this exception.
54  wxString ErrorMessage() const override;
55 
56  const char *func {};
57  const char *file {};
58  unsigned line {};
59 };
60 
61 // This macro constructs this exception type, using C++ preprocessor to identify
62 // the source code location.
63 
64 #ifdef __func__
65 
66 #define CONSTRUCT_INCONSISTENCY_EXCEPTION \
67  InconsistencyException( __func__, __FILE__ , __LINE__ )
68 
69 #else
70 
71 #define CONSTRUCT_INCONSISTENCY_EXCEPTION \
72  InconsistencyException( "", __FILE__ , __LINE__ )
73 
74 #endif
75 
76 #define THROW_INCONSISTENCY_EXCEPTION throw CONSTRUCT_INCONSISTENCY_EXCEPTION
77 
78 #endif
InconsistencyException(InconsistencyException &&that)
Definition: InconsistencyException.h:29
InconsistencyException & operator=(InconsistencyException &&that)
Definition: InconsistencyException.h:35
wxString ErrorMessage() const override
Definition: InconsistencyException.cpp:22
unsigned line
Definition: InconsistencyException.h:58
const char * func
Definition: InconsistencyException.h:56
std::unique_ptr< AudacityException > Move() override
Definition: InconsistencyException.cpp:16
const char * file
Definition: InconsistencyException.h:57
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
Definition: TrackControls.cpp:137
MessageBoxException & operator=(MessageBoxException &&)
Definition: AudacityException.cpp:55
unsigned GetLine() const
Definition: InconsistencyException.h:48
~InconsistencyException() override
Definition: InconsistencyException.cpp:12
Definition: InconsistencyException.h:18
InconsistencyException()
Definition: InconsistencyException.h:21
an AudacityException that pops up a single message box even if there were multiple exceptions of the ...
Definition: AudacityException.h:50