Differences between revisions 8 and 9
Revision 8 as of 2007-08-21 21:02:45
Size: 902
Editor: gtang
Comment:
Revision 9 as of 2007-08-21 21:03:01
Size: 902
Editor: gtang
Comment:
Deletions are marked like this. Additions are marked like this.
Line 16: Line 16:
 *
Line 36: Line 35:
 *
  • Here is an example on throwing an exception:

vector< float > EMData::calc_fourier_shell_correlation(EMData * with)
{
    if (!with) {
        throw NullPointerException("NULL input image");
    }
    if (!EMUtil::is_same_size(this, with)) {
        LOGERR("images not same size");
        throw ImageFormatException( "images not same size");
    }
//...
}
  • Here is an example on catching the exceptions:

void foo()
{
    EMData* e1 = new EMData();
    EMData* e2 = new EMData();
    try {
        e1->read_image("test1.mrc");
        e2->read_image("test2.mrc");
        vector<float> v = e1->calc_fourier_shell_correlation(e2);
    }
    catch (_NullPointerException & null_excp) {
        printf("%s\n", null_excp.what());
        // do something
    }
    catch (E2Exception & exception) {
        printf("%s\n", exception.what());
    }
}

eman2Exception (last edited 2022-02-18 00:42:07 by TunayDurmaz)