1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-15 16:17:41 +02:00

Export failure messages name the file, exactly as with FileException

This commit is contained in:
Paul Licameli 2020-12-06 14:20:02 -05:00
parent d225d24092
commit f07fd5d8bc
9 changed files with 20 additions and 18 deletions

View File

@ -27,12 +27,7 @@ TranslatableString FileException::ErrorMessage() const
format = XO("Audacity failed to read from a file in %s."); format = XO("Audacity failed to read from a file in %s.");
break; break;
case Cause::Write: case Cause::Write:
format = return WriteFailureMessage(fileName);
XO("Audacity failed to write to a file.\n"
"Perhaps %s is not writable or the disk is full.\n"
"For tips on freeing up space, click the help button."
);
break;
case Cause::Rename: case Cause::Rename:
format = format =
XO("Audacity successfully wrote a file in %s but failed to rename it as %s."); XO("Audacity successfully wrote a file in %s but failed to rename it as %s.");
@ -82,3 +77,12 @@ wxString FileException::AbbreviatePath( const wxFileName &fileName )
#endif #endif
return target; return target;
} }
TranslatableString
FileException::WriteFailureMessage(const wxFileName &fileName)
{
return XO("Audacity failed to write to a file.\n"
"Perhaps %s is not writable or the disk is full.\n"
"For tips on freeing up space, click the help button."
).Format(AbbreviatePath(fileName));
}

View File

@ -47,6 +47,7 @@ public:
~FileException() override; ~FileException() override;
static wxString AbbreviatePath(const wxFileName &fileName); static wxString AbbreviatePath(const wxFileName &fileName);
static TranslatableString WriteFailureMessage(const wxFileName &fileName);
protected: protected:
//! %Format an error message appropriate for the @ref Cause. //! %Format an error message appropriate for the @ref Cause.

View File

@ -1526,14 +1526,11 @@ void ShowExportErrorDialog(wxString ErrorCode,
); );
} }
void ShowDiskFullExportErrorDialog() void ShowDiskFullExportErrorDialog(const wxFileNameWrapper &fileName)
{ {
ShowErrorDialog(nullptr, ShowErrorDialog(nullptr,
XO("Warning"), XO("Warning"),
XO("Audacity failed to write to a file.\n" FileException::WriteFailureMessage(fileName),
"Perhaps the file is not writable or the disk is full.\n"
"For tips on freeing up space, click the help button."
),
"Error:_Disk_full_or_not_writable" "Error:_Disk_full_or_not_writable"
); );
} }

View File

@ -332,6 +332,6 @@ void ShowExportErrorDialog(wxString ErrorCode,
TranslatableString message = AudacityExportMessageStr(), TranslatableString message = AudacityExportMessageStr(),
const TranslatableString& caption = AudacityExportCaptionStr()); const TranslatableString& caption = AudacityExportCaptionStr());
void ShowDiskFullExportErrorDialog(); void ShowDiskFullExportErrorDialog(const wxFileNameWrapper &fileName);
#endif #endif

View File

@ -958,7 +958,7 @@ bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, size_t frameSize)
// Write the encoded audio frame to the output file. // Write the encoded audio frame to the output file.
if ((ret = av_interleaved_write_frame(mEncFormatCtx.get(), &pkt)) < 0) if ((ret = av_interleaved_write_frame(mEncFormatCtx.get(), &pkt)) < 0)
{ {
ShowDiskFullExportErrorDialog(); ShowDiskFullExportErrorDialog(mName);
return false; return false;
} }
} }
@ -1038,7 +1038,7 @@ ProgressResult ExportFFmpeg::Export(AudacityProject *project,
if (!EncodeAudioFrame( if (!EncodeAudioFrame(
pcmBuffer, (pcmNumSamples)*sizeof(int16_t)*mChannels)) { pcmBuffer, (pcmNumSamples)*sizeof(int16_t)*mChannels)) {
// All errors should already have been reported. // All errors should already have been reported.
//ShowDiskFullExportErrorDialog(); //ShowDiskFullExportErrorDialog(mName);
updateResult = ProgressResult::Cancelled; updateResult = ProgressResult::Cancelled;
break; break;
} }

View File

@ -407,7 +407,7 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
reinterpret_cast<FLAC__int32**>( tmpsmplbuf.get() ), reinterpret_cast<FLAC__int32**>( tmpsmplbuf.get() ),
samplesThisRun) ) { samplesThisRun) ) {
// TODO: more precise message // TODO: more precise message
ShowDiskFullExportErrorDialog(); ShowDiskFullExportErrorDialog(fName);
updateResult = ProgressResult::Cancelled; updateResult = ProgressResult::Cancelled;
break; break;
} }

View File

@ -342,7 +342,7 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
if ( outFile.Write(mp2Buffer.get(), mp2BufferNumBytes).GetLastError() ) { if ( outFile.Write(mp2Buffer.get(), mp2BufferNumBytes).GetLastError() ) {
// TODO: more precise message // TODO: more precise message
ShowDiskFullExportErrorDialog(); ShowDiskFullExportErrorDialog(fName);
return ProgressResult::Cancelled; return ProgressResult::Cancelled;
} }

View File

@ -1963,7 +1963,7 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
if (bytes > (int)outFile.Write(buffer.get(), bytes)) { if (bytes > (int)outFile.Write(buffer.get(), bytes)) {
// TODO: more precise message // TODO: more precise message
ShowDiskFullExportErrorDialog(); ShowDiskFullExportErrorDialog(fName);
updateResult = ProgressResult::Cancelled; updateResult = ProgressResult::Cancelled;
break; break;
} }

View File

@ -338,7 +338,7 @@ ProgressResult ExportOGG::Export(AudacityProject *project,
if ( outFile.Write(page.header, page.header_len).GetLastError() || if ( outFile.Write(page.header, page.header_len).GetLastError() ||
outFile.Write(page.body, page.body_len).GetLastError()) { outFile.Write(page.body, page.body_len).GetLastError()) {
// TODO: more precise message // TODO: more precise message
ShowDiskFullExportErrorDialog(); ShowDiskFullExportErrorDialog(fName);
return ProgressResult::Cancelled; return ProgressResult::Cancelled;
} }