@@ -581,27 +581,29 @@ void SpaceGroup::InitSpaceGroup(const string &spgId)
581
581
#endif
582
582
try
583
583
{
584
+ // replace mpCCTbxSpaceGroup only after we get new space group
584
585
cctbx::sgtbx::space_group_symbols sgs=cctbx::sgtbx::space_group_symbols (spgId);
585
- if (mpCCTbxSpaceGroup!=0 ) delete mpCCTbxSpaceGroup;
586
- mpCCTbxSpaceGroup=0 ;
587
- mpCCTbxSpaceGroup = new cctbx::sgtbx::space_group (sgs);
586
+ cctbx::sgtbx::space_group *nsg = new cctbx::sgtbx::space_group (sgs);
587
+ assert (nsg);
588
+ delete mpCCTbxSpaceGroup;
589
+ mpCCTbxSpaceGroup = nsg;
588
590
}
589
- catch (exception & ex1)
591
+ catch (cctbx::error ex1)
590
592
{
591
593
try
592
594
{
593
- (*fpObjCrystInformUser)(" Failed lookup symbol ! try Hall symbol ?" );
594
- if (mpCCTbxSpaceGroup!=0 ) delete mpCCTbxSpaceGroup;
595
- mpCCTbxSpaceGroup=0 ;
596
- mpCCTbxSpaceGroup = new cctbx::sgtbx::space_group (spgId);
595
+ (*fpObjCrystInformUser)(" Lookup of '" + spgId + " ' symbol failed, trying as Hall symbol." );
596
+ // replace mpCCTbxSpaceGroup only after we get new space group
597
+ cctbx::sgtbx::space_group *nsg = new cctbx::sgtbx::space_group (spgId);
598
+ assert (nsg);
599
+ delete mpCCTbxSpaceGroup;
600
+ mpCCTbxSpaceGroup = nsg;
597
601
}
598
- catch (exception & ex2)
602
+ catch (cctbx::error ex2)
599
603
{
600
604
(*fpObjCrystInformUser)(" Could not interpret Spacegroup Symbol:" +spgId);
601
- (*fpObjCrystInformUser)(" Reverting to spacegroup symbol:" +mId );
602
- this ->InitSpaceGroup (mId );
603
- VFN_DEBUG_EXIT (" SpaceGroup::InitSpaceGroup() could not interpret spacegroup:" <<spgId<<" :" <<ex1.what ()<<" :" <<ex2.what (),8 )
604
- return ;
605
+ string emsg = " Space group symbol '" + spgId + " ' not recognized" ;
606
+ throw invalid_argument (emsg);
605
607
}
606
608
}
607
609
@@ -642,13 +644,17 @@ void SpaceGroup::InitSpaceGroup(const string &spgId)
642
644
643
645
mExtension =' \0 ' ; // this->GetCCTbxSpg().type().extension();
644
646
}
645
- catch (exception & ex)
647
+ catch (cctbx::error ex)
646
648
{
647
649
(*fpObjCrystInformUser)(" Error initializing spacegroup (Incorrect Hall symbol ?):" +spgId);
648
- this ->InitSpaceGroup (mId );
649
- (*fpObjCrystInformUser)(" Reverting to spacegroup symbol:" +mId );
650
+ if (mId != spgId)
651
+ {
652
+ (*fpObjCrystInformUser)(" Reverting to spacegroup symbol:" +mId );
653
+ this ->InitSpaceGroup (mId );
654
+ }
650
655
VFN_DEBUG_EXIT (" SpaceGroup::InitSpaceGroup() could not interpret spacegroup:" <<spgId<<" :" <<ex.what (),8 )
651
- return ;
656
+ string emsg = " Space group symbol '" + spgId + " ' not recognized" ;
657
+ throw invalid_argument (emsg);
652
658
}
653
659
654
660
mExtension =this ->GetCCTbxSpg ().match_tabulated_settings ().extension ();
0 commit comments