Audacity  2.2.2
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
FileException Class Reference

#include <FileException.h>

Inheritance diagram for FileException:
MessageBoxException AudacityException NotYetAvailableException

Public Types

enum  Cause { Cause::Open, Cause::Read, Cause::Write, Cause::Rename }
 

Public Member Functions

 FileException (Cause cause_, const wxFileName &fileName_, const wxString &caption=_("File Error"), const wxFileName &renameTarget_={})
 
 FileException (FileException &&that)
 
FileExceptionoperator= (FileException &&) PROHIBITED
 
 ~FileException () override
 
- Public Member Functions inherited from AudacityException
 AudacityException ()
 
virtual ~AudacityException ()=0
 

Public Attributes

Cause cause
 
wxFileName fileName
 
wxFileName renameTarget
 

Protected Member Functions

wxString ErrorMessage () const override
 
- Protected Member Functions inherited from MessageBoxException
 MessageBoxException (const wxString &caption=wxString{})
 
 ~MessageBoxException () override
 
 MessageBoxException (const MessageBoxException &)
 
MessageBoxExceptionoperator= (MessageBoxException &&)
 
- Protected Member Functions inherited from AudacityException
 AudacityException (AudacityException &&)
 
 AudacityException (const AudacityException &)=default
 
AudacityExceptionoperator= (AudacityException &&)
 
AudacityExceptionoperator= (const AudacityException &) PROHIBITED
 

Detailed Description

Definition at line 15 of file FileException.h.

Member Enumeration Documentation

enum FileException::Cause
strong
Enumerator
Open 
Read 
Write 
Rename 

Definition at line 18 of file FileException.h.

18 { Open, Read, Write, Rename };

Constructor & Destructor Documentation

FileException::FileException ( Cause  cause_,
const wxFileName &  fileName_,
const wxString &  caption = _("File Error"),
const wxFileName &  renameTarget_ = {} 
)
inlineexplicit

Definition at line 21 of file FileException.h.

23  {})
25  , cause{ cause_ }, fileName{ fileName_ }, renameTarget{ renameTarget_ }
26  {}
wxFileName renameTarget
Definition: FileException.h:46
wxFileName fileName
Definition: FileException.h:45
an AudacityException that pops up a single message box even if there were multiple exceptions of the ...
FileException::FileException ( FileException &&  that)
inline

Definition at line 28 of file FileException.h.

29  : MessageBoxException(std::move(that))
30  , cause{ that.cause }
31  , fileName{ that.fileName }
32  , renameTarget{ that.renameTarget }
33  {}
wxFileName renameTarget
Definition: FileException.h:46
MessageBoxException(const wxString &caption=wxString{})
wxFileName fileName
Definition: FileException.h:45
FileException::~FileException ( )
override

Definition at line 14 of file FileException.cpp.

15 {
16 }

Member Function Documentation

wxString FileException::ErrorMessage ( ) const
overrideprotectedvirtual

Implements MessageBoxException.

Definition at line 18 of file FileException.cpp.

References _(), cause, fileName, format, Open, Read, Rename, renameTarget, and Write.

19 {
20  wxString format;
21  switch (cause) {
22  case Cause::Open:
23  format = _("Audacity failed to open a file in %s.");
24  break;
25  case Cause::Read:
26  format = _("Audacity failed to read from a file in %s.");
27  break;
28  case Cause::Write:
29  format =
30 _("Audacity failed to write to a file.\n"
31  "Perhaps %s is not writable or the disk is full.");
32  break;
33  case Cause::Rename:
34  format =
35 _("Audacity successfully wrote a file in %s but failed to rename it as %s.");
36  default:
37  break;
38  }
39  wxString target;
40 
41 #ifdef __WXMSW__
42 
43  // Drive letter plus colon
44  target = fileName.GetVolume() + wxT(":");
45 
46 #else
47 
48  // Shorten the path, arbitrarily to 3 components
49  auto path = fileName;
50  path.SetFullName(wxString{});
51  while(path.GetDirCount() > 3)
52  path.RemoveLastDir();
53  target = path.GetFullPath();
54 
55 #endif
56 
57  return wxString::Format(
58  format, target, renameTarget.GetFullName() );
59 }
wxFileName renameTarget
Definition: FileException.h:46
int format
Definition: ExportPCM.cpp:56
wxFileName fileName
Definition: FileException.h:45
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
FileException& FileException::operator= ( FileException &&  )

Member Data Documentation

Cause FileException::cause

Definition at line 44 of file FileException.h.

Referenced by ErrorMessage().

wxFileName FileException::fileName

Definition at line 45 of file FileException.h.

Referenced by NotYetAvailableException::ErrorMessage(), and ErrorMessage().

wxFileName FileException::renameTarget

Definition at line 46 of file FileException.h.

Referenced by ErrorMessage().


The documentation for this class was generated from the following files: