X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;h=769ca63f0bf4400cbb783cf53d3bd7b44b3fc293;hb=c134c94d6663e0678a41f801a96c81501f632887;hp=97808d8d870ba778887a8ba98542cd3ea7ddf8b5;hpb=da7742b2188d694446ffedc1835b778fb71849b7;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 97808d8..769ca63 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -48,6 +48,24 @@ namespace clitk { typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; + +#define CLITK_TRY_CATCH_EXIT(func) \ + try { \ + func; \ + } \ + catch (const itk::ExceptionObject& e) { \ + e.Print(std::cout); \ + exit(-1);\ + } \ + catch (const std::exception& e) { \ + std::cout << e.what() << std::endl; \ + exit(-2);\ + } \ + catch (...) { \ + std::cout << "Unknown excpetion" << std::endl; \ + exit(-3); \ + } + //-------------------------------------------------------------------- // when everything goes wrong