Audacity 3.2.0
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
17class FILES_API FileException /* not final */
18 : public MessageBoxException
19{
20public:
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
56protected:
58 TranslatableString ErrorMessage() const override;
59 wxString ErrorHelpUrl() const override;
60
61public:
63 wxFileName fileName;
64 wxFileName renameTarget;
65};
66
67#endif
Declare abstract class AudacityException, some often-used subclasses, and GuardedCall.
@ Internal
Indicates internal failure from Audacity.
XO("Cut/Copy/Paste")
AudacityException & operator=(const AudacityException &)=delete
Disallow assignment.
Thrown for failure of file or database operations in deeply nested places.
Definition: FileException.h:19
wxFileName renameTarget
Definition: FileException.h:64
wxFileName fileName
Definition: FileException.h:63
FileException(Cause cause_, const wxFileName &fileName_, const TranslatableString &caption=XO("File Error"), const wxFileName &renameTarget_={})
Definition: FileException.h:29
Cause
Identifies file operation that failed.
Definition: FileException.h:22
FileException(const FileException &that)
Definition: FileException.h:43
Abstract AudacityException subclass displays a message, specified by further subclass.
virtual TranslatableString ErrorMessage() const =0
Format the error message for this exception.
virtual wxString ErrorHelpUrl() const
Holds a msgid for the translation catalog; may also bind format arguments.