Clarified a bunch of error messages

Originally committed to SVN as r1433.
This commit is contained in:
Niels Martin Hansen 2007-07-18 13:46:38 +00:00
parent a446253e72
commit a0beaef640
20 changed files with 66 additions and 64 deletions

View File

@ -715,7 +715,7 @@ void AssDialogue::SetMarginString(const wxString origvalue,int which) {
if (value > 9999) value = 9999;
// Assign
if (which < 0 || which >= 4) throw _T("Invalid Margin");
if (which < 0 || which >= 4) throw _T("Invalid margin id");
Margin[which] = value;
}
@ -723,7 +723,7 @@ void AssDialogue::SetMarginString(const wxString origvalue,int which) {
//////////////////////////
// Gets string for margin
wxString AssDialogue::GetMarginString(int which,bool pad) {
if (which < 0 || which >= 4) throw _T("Invalid margin");
if (which < 0 || which >= 4) throw _T("Invalid margin id");
int value = Margin[which];
if (pad) return wxString::Format(_T("%04i"),value);
else return wxString::Format(_T("%i"),value);

View File

@ -408,7 +408,7 @@ int AssFile::AddLine (wxString data,wxString group,int lasttime,int &version,wxS
if (versionString == _T("v4.00")) trueVersion = 0;
else if (versionString == _T("v4.00+")) trueVersion = 1;
else if (versionString == _T("v4.00++")) trueVersion = 2;
else throw _T("Unknown file version");
else throw _T("Unknown SSA file format version");
if (trueVersion != version) {
if (!(trueVersion == 2 && version == 1)) wxLogMessage(_T("Warning: File has the wrong extension."));
version = trueVersion;

View File

@ -437,7 +437,7 @@ void AssStyle::UpdateData() {
/////////////////////////////
// Sets margin from a string
void AssStyle::SetMarginString(const wxString str,int which) {
if (which < 0 || which >= 4) throw _T("Invalid margin");
if (which < 0 || which >= 4) throw _T("Invalid margin id");
if (!str.IsNumber()) throw _T("Invalid margin value");
long value;
str.ToLong(&value);
@ -451,7 +451,7 @@ void AssStyle::SetMarginString(const wxString str,int which) {
//////////////////////////
// Gets string for margin
wxString AssStyle::GetMarginString(int which) {
if (which < 0 || which >= 4) throw _T("Invalid margin");
if (which < 0 || which >= 4) throw _T("Invalid margin id");
wxString result = wxString::Format(_T("%04i"),Margin[which]);
return result;
}

View File

@ -353,7 +353,7 @@ void AudioKaraoke::OnPaint(wxPaintEvent &event) {
dc.DrawLine(splitxpos, 0, splitxpos, h);
}
} else {
wxLogError(_T("WTF? Failed to GetPartialTextExtents"));
wxLogError(_T("Karaoke syllable display: Failed to GetPartialTextExtents. This should never happen, except on severely overloaded systems."));
}
}

View File

@ -148,7 +148,7 @@ void AlsaPlayer::OpenStream()
// Open device for blocking access
if (snd_pcm_open(&pcm_handle, device.mb_str(wxConvUTF8), stream, 0) < 0) { // supposedly we don't want SND_PCM_ASYNC even for async playback
throw _T("Error opening specified PCM device");
throw _T("ALSA player: Error opening specified PCM device");
}
SetUpHardware();
@ -171,12 +171,12 @@ void AlsaPlayer::SetUpHardware()
// Get hardware params
if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {
throw _T("Error setting up default PCM device");
throw _T("ALSA player: Error setting up default PCM device");
}
// Set stream format
if (snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) {
throw _T("Could not set interleaved stream format");
throw _T("ALSA player: Could not set interleaved stream format");
}
// Set sample format
@ -188,65 +188,65 @@ void AlsaPlayer::SetUpHardware()
sample_format = SND_PCM_FORMAT_S16_LE;
break;
default:
throw _T("Can only handle 8 and 16 bit sound");
throw _T("ALSA player: Can only handle 8 and 16 bit sound");
}
if (snd_pcm_hw_params_set_format(pcm_handle, hwparams, sample_format) < 0) {
throw _T("Could not set sample format");
throw _T("ALSA player: Could not set sample format");
}
// Ask for resampling
if (snd_pcm_hw_params_set_rate_resample(pcm_handle, hwparams, 1) < 0) {
throw _T("Couldn't enable resampling");
throw _T("ALSA player: Couldn't enable resampling");
}
// Set sample rate
rate = provider->GetSampleRate();
real_rate = rate;
if (snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0) < 0) {
throw _T("Could not set sample rate");
throw _T("ALSA player: Could not set sample rate");
}
if (rate != real_rate) {
wxLogDebug(_T("Could not set ideal sample rate %d, using %d instead"), rate, real_rate);
wxLogDebug(_T("ALSA player: Could not set ideal sample rate %d, using %d instead"), rate, real_rate);
}
// Set number of channels
if (snd_pcm_hw_params_set_channels(pcm_handle, hwparams, provider->GetChannels()) < 0) {
throw _T("Could not set number of channels");
throw _T("ALSA player: Could not set number of channels");
}
printf("Set sample rate %u (wanted %u)\n", real_rate, rate);
printf("ALSA player: Set sample rate %u (wanted %u)\n", real_rate, rate);
// Set buffer size
unsigned int wanted_buflen = 1000000; // microseconds
buflen = wanted_buflen;
if (snd_pcm_hw_params_set_buffer_time_near(pcm_handle, hwparams, &buflen, &dir) < 0) {
throw _T("Couldn't set buffer length");
throw _T("ALSA player: Couldn't set buffer length");
}
if (buflen != wanted_buflen) {
wxLogDebug(_T("Couldn't get wanted buffer size of %u, got %u instead"), wanted_buflen, buflen);
wxLogDebug(_T("ALSA player: Couldn't get wanted buffer size of %u, got %u instead"), wanted_buflen, buflen);
}
if (snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize) < 0) {
throw _T("Couldn't get buffer size");
throw _T("ALSA player: Couldn't get buffer size");
}
printf("Buffer size: %lu\n", bufsize);
printf("ALSA player: Buffer size: %lu\n", bufsize);
// Set period (number of frames ideally written at a time)
// Somewhat arbitrary for now
unsigned int wanted_period = bufsize / 4;
period_len = wanted_period; // microseconds
if (snd_pcm_hw_params_set_period_time_near(pcm_handle, hwparams, &period_len, &dir) < 0) {
throw _T("Couldn't set period length");
throw _T("ALSA player: Couldn't set period length");
}
if (period_len != wanted_period) {
wxLogDebug(_T("Couldn't get wanted period size of %d, got %d instead"), wanted_period, period_len);
wxLogDebug(_T("ALSA player: Couldn't get wanted period size of %d, got %d instead"), wanted_period, period_len);
}
if (snd_pcm_hw_params_get_period_size(hwparams, &period, &dir) < 0) {
throw _T("Couldn't get period size");
throw _T("ALSA player: Couldn't get period size");
}
printf("Period size: %lu\n", period);
printf("ALSA player: Period size: %lu\n", period);
// Apply parameters
if (snd_pcm_hw_params(pcm_handle, hwparams) < 0) {
throw _T("Failed applying sound hardware settings");
throw _T("ALSA player: Failed applying sound hardware settings");
}
// And free memory again
@ -262,22 +262,22 @@ void AlsaPlayer::SetUpAsync()
// Get current parameters
if (snd_pcm_sw_params_current(pcm_handle, sw_params) < 0) {
throw _T("Couldn't get current SW params");
throw _T("ALSA player: Couldn't get current SW params");
}
// How full the buffer must be before playback begins
if (snd_pcm_sw_params_set_start_threshold(pcm_handle, sw_params, bufsize - period) < 0) {
throw _T("Failed setting start threshold");
throw _T("ALSA player: Failed setting start threshold");
}
// The the largest write guaranteed never to block
if (snd_pcm_sw_params_set_avail_min(pcm_handle, sw_params, period) < 0) {
throw _T("Failed setting min available buffer");
throw _T("ALSA player: Failed setting min available buffer");
}
// Apply settings
if (snd_pcm_sw_params(pcm_handle, sw_params) < 0) {
throw _T("Failed applying SW params");
throw _T("ALSA player: Failed applying SW params");
}
// And free struct again
@ -285,7 +285,7 @@ void AlsaPlayer::SetUpAsync()
// Attach async handler
if (snd_async_add_pcm_handler(&pcm_callback, pcm_handle, async_write_handler, this) < 0) {
throw _T("Failed attaching async handler");
throw _T("ALSA player: Failed attaching async handler");
}
}

View File

@ -192,6 +192,7 @@ void PulseAudioPlayer::OpenStream()
pa_threaded_mainloop_stop(mainloop);
pa_threaded_mainloop_free(mainloop);
wxString s(pa_strerror(paerror), wxConvUTF8);
s.Prepend(_T("PulseAudio reported error: "));
throw s.c_str();
}
// otherwise loop once more
@ -219,12 +220,13 @@ void PulseAudioPlayer::OpenStream()
pa_stream_set_state_callback(stream, (pa_stream_notify_cb_t)pa_stream_notify, this);
pa_stream_set_write_callback(stream, (pa_stream_request_cb_t)pa_stream_write, this);
// Connext stream
// Connect stream
//printf("Connecting playback stream\n");
paerror = pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_NOT_MONOTONOUS|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL);
if (paerror) {
printf("PulseAudio reported error: %s (%d)\n", pa_strerror(paerror), paerror);
wxString s(pa_strerror(paerror), wxConvUTF8);
s.Prepend(_T("PulseAudio reported error: "));
throw s.c_str();
}
while (true) {
@ -233,8 +235,8 @@ void PulseAudioPlayer::OpenStream()
break;
} else if (sstate == PA_STREAM_FAILED) {
paerror = pa_context_errno(context);
printf("Stream connection failed: %s (%d)\n", pa_strerror(paerror), paerror);
throw _T("Something went wrong connecting the stream");
printf("PulseAudio player: Stream connection failed: %s (%d)\n", pa_strerror(paerror), paerror);
throw _T("PulseAudio player: Something went wrong connecting the stream");
}
}
//printf("Connected playback stream, now playing\n\n");
@ -285,7 +287,7 @@ void PulseAudioPlayer::Play(__int64 start,__int64 count)
pa_operation_unref(op);
if (!stream_success_val) {
paerror = pa_context_errno(context);
printf("Error flushing stream: %s (%d)\n", pa_strerror(paerror), paerror);
printf("PulseAudio player: Error flushing stream: %s (%d)\n", pa_strerror(paerror), paerror);
}
}
@ -301,7 +303,7 @@ void PulseAudioPlayer::Play(__int64 start,__int64 count)
paerror = pa_stream_get_time(stream, &play_start_time);
pa_threaded_mainloop_unlock(mainloop);
if (paerror) {
printf("Error getting stream time: %s (%d)\n", pa_strerror(paerror), paerror);
printf("PulseAudio player: Error getting stream time: %s (%d)\n", pa_strerror(paerror), paerror);
}
PulseAudioPlayer::pa_stream_write(stream, pa_stream_writable_size(stream), this);
@ -313,7 +315,7 @@ void PulseAudioPlayer::Play(__int64 start,__int64 count)
pa_operation_unref(op);
if (!stream_success_val) {
paerror = pa_context_errno(context);
printf("Error triggering stream: %s (%d)\n", pa_strerror(paerror), paerror);
printf("PulseAudio player: Error triggering stream: %s (%d)\n", pa_strerror(paerror), paerror);
}
// Update timer
@ -343,7 +345,7 @@ void PulseAudioPlayer::Stop(bool timerToo)
pa_operation_unref(op);
if (!stream_success_val) {
paerror = pa_context_errno(context);
printf("Error flushing stream: %s (%d)\n", pa_strerror(paerror), paerror);
printf("PulseAudio player: Error flushing stream: %s (%d)\n", pa_strerror(paerror), paerror);
}
// And unref it

View File

@ -60,7 +60,7 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
wxLongLong freespace;
if (wxGetDiskSpace(DiskCachePath(), NULL, &freespace)) {
if (num_samples * channels * bytes_per_sample > freespace) {
throw wxString(_T("Not enough free diskspace in "))+DiskCachePath()+wxString(_T(" to cache the audio"));
throw wxString(_T("Not enough free disk space in "))+DiskCachePath()+wxString(_T(" to cache the audio"));
}
}
@ -68,7 +68,7 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
diskCacheFilename = DiskCacheName();
file_cache.Create(diskCacheFilename,true,wxS_DEFAULT);
file_cache.Open(diskCacheFilename,wxFile::read_write);
if (!file_cache.IsOpened()) throw _T("Unable to write to disk cache.");
if (!file_cache.IsOpened()) throw _T("Unable to write to audio disk cache.");
// Start progress
volatile bool canceled = false;

View File

@ -588,7 +588,7 @@ void DialogStyleEditor::OnSetColor (int n) {
case 2: modify = &work->secondary; break;
case 3: modify = &work->outline; break;
case 4: modify = &work->shadow; break;
default: throw _T("Never gets here");
default: throw _T("Internal error in style editor, attempted setting colour id outside range");
}
modify->SetWXColor(colorButton[n-1]->GetColour());
if (SubsPreview) SubsPreview->SetStyle(work);

View File

@ -235,7 +235,7 @@ void DialogStyleManager::LoadCatalog () {
wxString dirname = StandardPaths::DecodePath(_T("?user/catalog/"));
if (!wxDirExists(dirname)) {
if (!wxMkdir(dirname)) {
throw _T("Error creating directory!");
throw _T("Failed creating directory for style catalogues");
}
else {
// Create default style
@ -441,7 +441,7 @@ void DialogStyleManager::OnCatalogNew (wxCommandEvent &event) {
wxString dirname = StandardPaths::DecodePath(_T("?user/catalog/"));
if (!wxDirExists(dirname)) {
if (!wxMkdir(dirname)) {
throw _T("Error creating directory!");
throw _T("Failed creating directory for style catalogues");
}
}
Store.Save(name);

View File

@ -561,7 +561,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
// File exists?
if (isFile) {
wxFileName fileCheck(filename);
if (!fileCheck.FileExists()) throw _T("File does not exist.");
if (!fileCheck.FileExists()) throw _T("Selected file does not exist.");
// Make sure that file isn't actually a timecode file
TextFileReader testSubs(filename);
@ -1074,9 +1074,9 @@ void FrameMain::LoadKeyframes(wxString filename) {
// Read header
wxString cur = file.ReadLineFromFile();
if (cur != _T("# keyframe format v1")) throw _T("Invalid keyframes file.");
if (cur != _T("# keyframe format v1")) throw _T("Invalid keyframes file, missing header.");
cur = file.ReadLineFromFile();
if (cur.Left(4) != _T("fps ")) throw _T("Invalid keyframes file.");
if (cur.Left(4) != _T("fps ")) throw _T("Invalid keyframes file, missing FPS.");
cur = cur.Mid(4);
double fps;
cur.ToDouble(&fps);

View File

@ -689,7 +689,7 @@ void FrameMain::OnExportSubtitles(wxCommandEvent & WXUNUSED(event)) {
scripts[i]->Reload();
}
catch (const wchar_t *e) {
wxLogError(e);
wxLogError(_T("Error while reloading Automation scripts before export: %s", e.c_str());
}
catch (...) {
wxLogError(_T("An unknown error occurred reloading Automation script '%s'."), scripts[i]->GetName().c_str());

View File

@ -263,7 +263,7 @@ OpenGLTextTexture::OpenGLTextTexture(int w,int h) {
// Allocate texture
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,width,height,0,GL_ALPHA,GL_UNSIGNED_BYTE,NULL);
if (glGetError()) throw _T("Could not allocate Text Texture");
if (glGetError()) throw _T("Internal OpenGL text renderer error: Could not allocate Text Texture");
}
@ -350,7 +350,7 @@ void OpenGLTextTexture::Insert(OpenGLTextGlyph &glyph) {
glBindTexture(GL_TEXTURE_2D, tex);
glTexSubImage2D(GL_TEXTURE_2D,0,x,y,imgw,imgh,GL_LUMINANCE_ALPHA,GL_UNSIGNED_BYTE,alpha);
delete[] alpha;
if (glGetError()) throw _T("Error uploading glyph data to video memory.");
if (glGetError()) throw _T("Internal OpenGL text renderer error: Error uploading glyph data to video memory.");
}

View File

@ -313,7 +313,7 @@ void MatroskaWrapper::GetSubtitles(AssFile *target) {
if (tracksFound.Count() == 0) {
target->LoadDefault(true);
Close();
throw _T("File has no known subtitle tracks.");
throw _T("File has no recognised subtitle tracks.");
}
// Only one track found

View File

@ -410,7 +410,7 @@ void OptionsManager::Load() {
// Read header
TextFileReader file(filename);
wxString header = file.ReadLineFromFile();
if (header != _T("[Config]")) throw _T("Invalid config file");
if (header != _T("[Config]")) throw _T("Configuration file is invalid");
// Get variables
std::map<wxString,VariableData>::iterator cur;
@ -495,7 +495,7 @@ int OptionsManager::AsInt(wxString key) {
if (cur != opt.end()) {
return (*cur).second.AsInt();
}
else throw _T("Undefined name");
else throw _T("Internal error: Attempted getting undefined configuration setting");
}
@ -507,7 +507,7 @@ bool OptionsManager::AsBool(wxString key) {
if (cur != opt.end()) {
return (*cur).second.AsBool();
}
else throw _T("Undefined name");
else throw _T("Internal error: Attempted getting undefined configuration setting");
}
@ -519,7 +519,7 @@ double OptionsManager::AsFloat(wxString key) {
if (cur != opt.end()) {
return (*cur).second.AsFloat();
}
else throw _T("Undefined name");
else throw _T("Internal error: Attempted getting undefined configuration setting");
}
@ -531,7 +531,7 @@ wxString OptionsManager::AsText(wxString key) {
if (cur != opt.end()) {
return (*cur).second.AsText();
}
else throw _T("Undefined name");
else throw _T("Internal error: Attempted getting undefined configuration setting");
}
@ -543,7 +543,7 @@ wxColour OptionsManager::AsColour(wxString key) {
if (cur != opt.end()) {
return (*cur).second.AsColour();
}
else throw _T("Undefined name");
else throw _T("Internal error: Attempted getting undefined configuration setting");
}

View File

@ -574,7 +574,7 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &event) {
bool cont;
wxArrayInt sel = GetSelection(&cont);
int nSel = sel.Count();
if ((nSel != 2 && nSel != 3) || !cont) throw _T("Invalid selection");
if ((nSel != 2 && nSel != 3) || !cont) throw _T("Invalid selection for recombining");
int n = sel[0];
// Get dialogues

View File

@ -227,7 +227,7 @@ void TTXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
WriteLine(root,current);
i++;
}
else throw _T("Unexpected line type");
else throw _T("Unexpected line type in TTXT file");
}
// Save XML

View File

@ -204,7 +204,7 @@ void FrameRate::Load(wxString filename) {
// Unknown
else {
throw _T("Unknown file format.");
throw _T("Unknown time code file format.");
}
}

View File

@ -59,7 +59,7 @@ wxArrayInt VFWWrapper::GetKeyFrames(wxString filename) {
long hr = AVIFileOpen(&pfile, filename.wc_str(), OF_SHARE_DENY_WRITE, 0);
if (hr != 0) {
AVIFileExit();
throw _T("Unable to open file.");
throw _T("Unable to open AVI file for reading keyframes.");
}
// Open stream
@ -68,7 +68,7 @@ wxArrayInt VFWWrapper::GetKeyFrames(wxString filename) {
if (hr != 0) {
AVIFileRelease(pfile);
AVIFileExit();
throw _T("Unable to open stream.");
throw _T("Unable to open AVI stream for reading keyframes.");
}
// Get stream data

View File

@ -78,7 +78,7 @@ const AegiVideoFrame VideoProvider::GetFrame(int n,int format) {
// Convert to compatible format
if (!(frame.format & format)) {
if (format & FORMAT_RGB32) tempRGBFrame.format = FORMAT_RGB32;
else throw _T("Unable to negotiate formats.");
else throw _T("Unable to negotiate video frame format.");
tempRGBFrame.w = frame.w;
tempRGBFrame.h = frame.h;
tempRGBFrame.pitch[0] = frame.w * 4;

View File

@ -315,7 +315,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
// Check if video was loaded properly
if (!script.AsClip()->GetVideoInfo().HasVideo()) {
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: No suitable video found"));
throw _T("No usable video found in ") + _filename;
throw _T("Avisynth: No usable video found in ") + _filename;
}
// Convert to RGB32
@ -513,7 +513,7 @@ void AvisynthVideoProvider::LoadVSFilter() {
}
else if (!env->FunctionExists("TextSub")) {
AVSTRACE(_T("AvisynthVideoProvider::LoadVSFilter: Couldn't locate VSFilter"));
throw _T("Couldn't locate VSFilter");
throw _T("Couldn't locate VSFilter for Avisynth internal subtitle rendering");
}
}
}
@ -542,7 +542,7 @@ void AvisynthVideoProvider::LoadASA() {
}
else if (!env->FunctionExists("asa")) {
AVSTRACE(_T("AvisynthVideoProvider::LoadASA: Couldn't locate asa"));
throw _T("Couldn't locate asa");
throw _T("Couldn't locate asa for Avisynth internal subtitle rendering");
}
}
}