CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/DQMServices/Core/src/DQMError.cc

Go to the documentation of this file.
00001 #include "DQMServices/Core/src/DQMError.h"
00002 #include <stdarg.h>
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 
00006 #if WITHOUT_CMS_FRAMEWORK
00007 static const char FAILED[] = "(out of memory while formatting error message)";
00008 #endif
00009 
00010 void
00011 raiseDQMError(const char *context, const char *fmt, ...)
00012 {
00013   va_list args;
00014   char *message = 0;
00015 
00016   va_start(args, fmt);
00017   vasprintf(&message, fmt, args);
00018   va_end(args);
00019 
00020 #if WITHOUT_CMS_FRAMEWORK
00021   char *final = 0;
00022   asprintf(&final, "%s: %s", context, message ? message : FAILED);
00023   std::runtime_error err(final ? final : FAILED);
00024   free(final);
00025 #else
00026   cms::Exception err(context);
00027   if (message)
00028     err << message;
00029 #endif
00030 
00031   free(message);
00032   throw err;
00033 }