Browse Source

Print out exception details in some places where it may be useful

Michael Hansen 10 years ago
parent
commit
dc4d428eb2
  1. 10
      Sources/Plasma/Apps/plPageOptimizer/main.cpp
  2. 6
      Sources/Plasma/PubUtilLib/plAudio/plEAXEffects.cpp
  3. 8
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp
  4. 13
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp
  5. 18
      Sources/Plasma/PubUtilLib/plGImage/plJPEG.cpp
  6. 14
      Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp
  7. 12
      Sources/Plasma/PubUtilLib/plSDL/plSDLMgr.cpp
  8. 14
      Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp

10
Sources/Plasma/Apps/plPageOptimizer/main.cpp

@ -61,6 +61,9 @@ int main(int argc, char* argv[])
plResManager* resMgr = new plResManager;
hsgResMgr::Init(resMgr);
#ifndef _DEBUG
} catch (std::exception &e) {
printf(" ***crashed on init: %s\n", e.what());
return 2;
} catch (...) {
puts(" ***crashed on init");
return 2;
@ -75,6 +78,10 @@ int main(int argc, char* argv[])
optimizer.Optimize();
}
#ifndef _DEBUG
catch (std::exception &e) {
printf(" ***crashed on optimizing: %s\n", e.what());
return 2;
}
catch (...) {
puts(" ***crashed on optimizing");
return 2;
@ -92,6 +99,9 @@ int main(int argc, char* argv[])
hsgResMgr::Shutdown();
#ifndef _DEBUG
} catch (std::exception &e) {
printf(" ***crashed on shutdown: %s\n", e.what());
return 2;
} catch (...) {
puts(" ***crashed on shutdown");
return 2;

6
Sources/Plasma/PubUtilLib/plAudio/plEAXEffects.cpp

@ -150,6 +150,12 @@ bool plEAXListener::Init( void )
SetGlobalEAXProperty(DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ROOM, &lRoom, sizeof( unsigned int ));
}
catch (std::exception &e)
{
plStatusLog::AddLineS("audio.log", "Unable to set EAX Property Set (%s), disabling EAX...", e.what());
plgAudioSys::EnableEAX(false);
return false;
}
catch (...)
{
plStatusLog::AddLineS("audio.log", "Unable to set EAX Property Set, disabling EAX...");

8
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp

@ -161,11 +161,13 @@ bool plAvBrainHuman::Apply(double timeNow, float elapsed)
plArmatureBrain::Apply(timeNow, elapsed);
#ifndef _DEBUG
} catch (...)
{
} catch (std::exception &e) {
plStatusLog *log = plAvatarMgr::GetInstance()->GetLog();
log->AddLineF("plAvBrainHuman::Apply - exception caught: %s", e.what());
} catch (...) {
// just catch all the crashes on exit...
plStatusLog *log = plAvatarMgr::GetInstance()->GetLog();
log->AddLine("plAvBrainHuman::Apply - crash caught");
log->AddLine("plAvBrainHuman::Apply - exception caught");
}
#endif

13
Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

@ -1475,6 +1475,12 @@ bool plFont::LoadFromFNTStream( hsStream *stream )
ICalcFontAscent();
return true;
}
catch (std::exception &e)
{
printf("Exception caught in plFont::LoadFromFNTStream: %s\n", e.what());
IClear();
return false;
}
catch (...)
{
// Somehow we crashed converting!
@ -2092,6 +2098,13 @@ bool plFont::LoadFromBDF( const plFileName &path, plBDFConvertCallback *callb
}
}
}
catch (std::exception &e)
{
printf("Exception caught in plFont::LoadFromBDF: %s\n", e.what());
IClear();
fclose(fp);
return false;
}
catch (...)
{
IClear();

18
Sources/Plasma/PubUtilLib/plGImage/plJPEG.cpp

@ -73,7 +73,7 @@ static char jpegmsg[JMSG_LENGTH_MAX];
static void plJPEG_error_exit( j_common_ptr cinfo )
{
(*cinfo->err->format_message) ( cinfo, jpegmsg );
throw ( false );
throw false;
}
static void plJPEG_emit_message( j_common_ptr cinfo, int msg_level )
{
@ -134,7 +134,7 @@ plMipmap *plJPEG::IRead( hsStream *inStream )
/// Read in the JPEG header
if ( inStream->GetEOF() == 0 )
throw( false );
throw false;
/// Wonderful limitation of mixing our streams with IJL--it wants either a filename
/// or a memory buffer. Since we can't give it the former, we have to read the entire
@ -142,11 +142,6 @@ plMipmap *plJPEG::IRead( hsStream *inStream )
/// have to write/read a length of said buffer. Such is life, I guess...
jpegSourceSize = inStream->ReadLE32();
jpegSourceBuffer = new uint8_t[ jpegSourceSize ];
if( jpegSourceBuffer == nil )
{
// waah.
ERREXIT1( &cinfo, JERR_OUT_OF_MEMORY, 0 );
}
inStream->Read( jpegSourceSize, jpegSourceBuffer );
jpeg_mem_src( &cinfo, jpegSourceBuffer, jpegSourceSize );
@ -183,11 +178,6 @@ plMipmap *plJPEG::IRead( hsStream *inStream )
/// Construct a new mipmap to hold everything
newMipmap = new plMipmap( cinfo.output_width, cinfo.output_height, plMipmap::kRGB32Config, 1, plMipmap::kJPEGCompression );
if( newMipmap == nil || newMipmap->GetImage() == nil )
{
ERREXIT1( &cinfo, JERR_OUT_OF_MEMORY, 0 );
}
/// Set up to read in to that buffer we now have
JSAMPROW jbuffer;
int row_stride = cinfo.output_width * cinfo.output_components;
@ -282,10 +272,6 @@ bool plJPEG::IWrite( plMipmap *source, hsStream *outStream )
// Create a buffer to hold the data
jpgBufferSize = source->GetWidth() * source->GetHeight() * 3;
jpgBuffer = new uint8_t[ jpgBufferSize ];
if( jpgBuffer == nil )
{
ERREXIT1( &cinfo, JERR_OUT_OF_MEMORY, 0 );
}
uint8_t *bufferAddr = jpgBuffer;
unsigned long bufferSize = jpgBufferSize;

14
Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp

@ -95,21 +95,21 @@ plMipmap* plPNG::IRead(hsStream* inStream)
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
throw(false);
throw false;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
throw(false);
throw false;
}
end_info = png_create_info_struct(png_ptr);
if (!end_info) {
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
throw(false);
throw false;
}
// Assign delegate function for reading from hsStream
@ -169,10 +169,8 @@ plMipmap* plPNG::IRead(hsStream* inStream)
delete [] row_ptrs;
}
} catch (...) {
if (newMipmap != NULL) {
delete newMipmap;
newMipmap = NULL;
}
newMipmap = nullptr;
}
return newMipmap;
@ -200,14 +198,14 @@ bool plPNG::IWrite(plMipmap* source, hsStream* outStream)
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
throw(false);
throw false;
}
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
throw(false);
throw false;
}
// Assign delegate function for writing to hsStream

12
Sources/Plasma/PubUtilLib/plSDL/plSDLMgr.cpp

@ -191,6 +191,18 @@ int plSDLMgr::Read(hsStream* s, plSDL::DescriptorList* dl)
delete sd; // well that sucked
}
}
catch (std::exception &e)
{
if (fNetApp)
{
hsLogEntry(fNetApp->DebugMsg("Something bad happened while reading SDLMgr data: %s", e.what()));
}
else
{
DebugMsg("Something bad happened while reading SDLMgr data: %s", e.what());
}
return 0;
}
catch (...)
{
if (fNetApp)

14
Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp

@ -274,6 +274,13 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
}
}
}
catch (std::exception &e)
{
hsAssert(false,
plFormat("Something bad happened ({}) while reading simple var data, desc:{}",
e.what(), fDescriptor ? fDescriptor->GetName() : "?").c_str());
return false;
}
catch (...)
{
hsAssert(false,
@ -308,6 +315,13 @@ bool plStateDataRecord::Read(hsStream* s, float timeConvert, uint32_t readOption
}
}
}
catch (std::exception &e)
{
hsAssert(false,
plFormat("Something bad happened ({}) while reading nested var data, desc:{}",
e.what(), fDescriptor ? fDescriptor->GetName() : "?").c_str());
return false;
}
catch (...)
{
hsAssert(false,

Loading…
Cancel
Save