Page 1 of 1

Unhandled exception in reading TRC file

Posted: Mon Mar 09, 2015 11:43 pm
by fantasymew
Hello,

I encounter an unhandled exception in C++ code when reading a TRC file with bad data (for example, negative value of camera rate, no frame, or others), but I cannot catch this exception. Even if I use std::set_terminate, it does not work. I want to do a sanity check on TRC file so that OpenSim tool such as Scaling or IK will not get stuck if there are errors in TRC file. I need some help. Thank you very much.

Code: Select all

	string trcFile = "mypath\\test.trc";
	
	try {
		MarkerData markerData = MarkerData(trcFile);
		int numFrames = markerData.getNumFrames();
		cout << numFrames << endl;
	}

	catch (OpenSim::Exception ex)
    {
        std::cout << ex.getMessage() << std::endl;
        return 1;
    }
    catch (SimTK::Exception::Base ex)
    {
        std::cout << ex.getMessage() << std::endl;
        return 1;
    }
    catch (std::exception ex)
    {
        std::cout << ex.what() << std::endl;
        return 1;
    }
    catch (...)
    {
        std::cout << "UNRECOGNIZED EXCEPTION" << std::endl;
        return 1;
    }
Best regards,
Yu-Wei