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  : func { fn }, file { f }, line { l }
26  {}
27 
29  : MessageBoxException(std::move(that))
30  , func{ that.func }
31  , file{ that.file }
32  , line{ that.line }
33  {}
35  {
36  if (this != &that) {
37  MessageBoxException::operator= (std::move(that));
38  func = that.func;
39  file = that.file;
40  line = that.line;
41  }
42  return *this;
43  }
44 
45  ~InconsistencyException() override;
46 
47 private:
48  std::unique_ptr< AudacityException > Move() override;
49 
50  // Format a default, internationalized error message for this exception.
51  wxString ErrorMessage() const override;
52 
53  const char *func {};
54  const char *file {};
55  unsigned line {};
56 };
57 
58 // This macro constructs this exception type, using C++ preprocessor to identify
59 // the source code location.
60 
61 #ifdef __func__
62 
63 #define CONSTRUCT_INCONSISTENCY_EXCEPTION \
64  InconsistencyException( __func__, __FILE__ , __LINE__ )
65 
66 #else
67 
68 #define CONSTRUCT_INCONSISTENCY_EXCEPTION \
69  InconsistencyException( "", __FILE__ , __LINE__ )
70 
71 #endif
72 
73 #define THROW_INCONSISTENCY_EXCEPTION throw CONSTRUCT_INCONSISTENCY_EXCEPTION
74 
75 #endif
InconsistencyException(InconsistencyException &&that)
Definition: InconsistencyException.h:28
InconsistencyException & operator=(InconsistencyException &&that)
Definition: InconsistencyException.h:34
wxString ErrorMessage() const override
Definition: InconsistencyException.cpp:22
unsigned line
Definition: InconsistencyException.h:55
const char * func
Definition: InconsistencyException.h:53
std::unique_ptr< AudacityException > Move() override
Definition: InconsistencyException.cpp:16
const char * file
Definition: InconsistencyException.h:54
MessageBoxException & operator=(MessageBoxException &&)
Definition: AudacityException.cpp:30
~InconsistencyException() override
Definition: InconsistencyException.cpp:12
Definition: InconsistencyException.h:18
InconsistencyException()
Definition: InconsistencyException.h:21
Definition: AudacityException.h:50