X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;h=9eb36522004c172b9cfa6d8bb209f45821cb02f5;hb=497f4e3a54a75a1dce99ad4a94a3aaa1ea904323;hp=97808d8d870ba778887a8ba98542cd3ea7ddf8b5;hpb=da7742b2188d694446ffedc1835b778fb71849b7;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 97808d8..9eb3652 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -38,7 +38,7 @@ #if defined(unix) || defined(__APPLE__) # include # include -#elif defined(WIN32) +#elif defined(_WIN32) # include #endif @@ -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