Audacity  3.0.3
FileException.h
Go to the documentation of this file.
1 
10 #ifndef __AUDACITY_FILE_EXCEPTION__
11 #define __AUDACITY_FILE_EXCEPTION__
12 
13 #include "AudacityException.h" // to inherit
14 #include <wx/filename.h> // wxFileName member variable
15 
17 class FILES_API FileException /* not final */
18  : public MessageBoxException
19 {
20 public:
22  enum class Cause {
23  Open,
24  Read,
25  Write,
26  Rename
27  };
28 
29  explicit FileException(
30  Cause cause_,
31  const wxFileName &fileName_,
32  const TranslatableString &caption = XO("File Error"),
33  const wxFileName &renameTarget_ = {}
34  )
35  // DV: We consider a FileException to be internal for now.
36  // We used to have some odd cases related to the read-only folder in 3.0.0,
37  // so it is good to have a full picture here.
38  // In case we see too many - we will tweak this behavior in the next release.
40  , cause{ cause_ }, fileName{ fileName_ }, renameTarget{ renameTarget_ }
41  {}
42 
44  : MessageBoxException( that )
45  , cause{ that.cause }
46  , fileName{ that.fileName }
47  , renameTarget{ that.renameTarget }
48  {}
49 
51 
52  ~FileException() override;
53 
54  static TranslatableString WriteFailureMessage(const wxFileName &fileName);
55 
56 protected:
58  TranslatableString ErrorMessage() const override;
59  wxString ErrorHelpUrl() const override;
60 
61 public:
63  wxFileName fileName;
64  wxFileName renameTarget;
65 };
66 
67 #endif
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
FileException::cause
Cause cause
Definition: FileException.h:62
FileException::FileException
FileException(const FileException &that)
Definition: FileException.h:43
FileException
Thrown for failure of file or database operations in deeply nested places.
Definition: FileException.h:19
XO
#define XO(s)
Definition: Internat.h:31
FileException::fileName
wxFileName fileName
Definition: FileException.h:63
MessageBoxException::ErrorHelpUrl
virtual wxString ErrorHelpUrl() const
Definition: AudacityException.h:81
FileException::FileException
FileException(Cause cause_, const wxFileName &fileName_, const TranslatableString &caption=XO("File Error"), const wxFileName &renameTarget_={})
Definition: FileException.h:29
MessageBoxException::ErrorMessage
virtual TranslatableString ErrorMessage() const =0
Format the error message for this exception.
AudacityException.h
Declare abstract class AudacityException, some often-used subclasses, and GuardedCall.
FileException::Cause
Cause
Identifies file operation that failed.
Definition: FileException.h:22
Read
gPrefs Read(wxT("/GUI/VerticalZooming"), &bVZoom, false)
MessageBoxException
Abstract AudacityException subclass displays a message, specified by further subclass.
Definition: AudacityException.h:62
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
AudacityException::operator=
AudacityException & operator=(const AudacityException &) PROHIBITED
Disallow assignment.
FileException::renameTarget
wxFileName renameTarget
Definition: FileException.h:64