From 629a1bbc1457074bb31c60321407752026faa1be Mon Sep 17 00:00:00 2001 From: oparviai Date: Sun, 17 Jul 2011 10:40:27 +0000 Subject: [PATCH] Repaired int-to-string conversion in exception message formatting --- source/SoundStretch/WavFile.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/SoundStretch/WavFile.cpp b/source/SoundStretch/WavFile.cpp index 9264b45..31760c9 100644 --- a/source/SoundStretch/WavFile.cpp +++ b/source/SoundStretch/WavFile.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -283,10 +284,11 @@ int WavInFile::read(short *buffer, int maxElems) // 16 bit format if (header.format.bits_per_sample != 16) { - string msg = "WAV file bits per sample format not supported: "; - msg += (int)header.format.bits_per_sample; - msg += " bits per sample."; - throw runtime_error(msg); + stringstream ss; + ss << "\nOnly 8/16 bit sample WAV files supported. Can't open WAV file with "; + ss << (int)header.format.bits_per_sample; + ss << " bit sample format. "; + throw runtime_error(ss.str()); } assert(sizeof(short) == 2); @@ -711,10 +713,11 @@ void WavOutFile::write(const short *buffer, int numElems) if (header.format.bits_per_sample != 16) { - string msg = "WAV file bits per sample format not supported: "; - msg += (int)header.format.bits_per_sample; - msg += " bits per sample."; - throw runtime_error(msg); + stringstream ss; + ss << "\nOnly 8/16 bit sample WAV files supported. Can't open WAV file with "; + ss << (int)header.format.bits_per_sample; + ss << " bit sample format. "; + throw runtime_error(ss.str()); } // allocate temp buffer to swap byte order if necessary