<commit_before>/*=========================================================================

Program:   Medical Imaging & Interaction Toolkit
Language:  C++
Date:      $Date$
Version:   $Revision$

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#ifndef MITK_EXCEPTIONMACRO_H_DEFINED
#define MITK_EXCEPTIONMACRO_H_DEFINED

#include "mitkException.h"
#include <itkMacro.h>
#include <mitkLogMacros.h>

/** The exception macro is used to print error information (i.e., usually
 * a condition that results in program failure). Example usage looks like:
 * mitkExceptionMacro(<< "this is error info" << this->SomeVariable); */
#define mitkExceptionMacro(messagetext) \
  { \
  ::itk::OStringStream message; \
  message << "mitk::EXCEPTION: " << this->GetNameOfClass() \
          << "(" << this << "): " messagetext; \
  MITK_DEBUG << message.str().c_str(); /* Print a MITK debug message to log exceptions in debug mode. */ \
  throw mitk::Exception(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION); \
  }

#define mitkSpecializedExceptionMacro(messagetext,classname) \
  { \
  ::itk::OStringStream message; \
  message << "mitk::EXCEPTION: " << this->GetNameOfClass() \
          << "(" << this << "): " messagetext; \
  MITK_DEBUG << message.str().c_str(); /* Print a MITK debug message to log exceptions in debug mode. */ \
  throw classname(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION); /* Explicit naming to work around Intel compiler bug.  */ \
  }
  
#endif<commit_msg>added documentation to exception macros and simplified code<commit_after>/*=========================================================================

Program:   Medical Imaging & Interaction Toolkit
Language:  C++
Date:      $Date$
Version:   $Revision$

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#ifndef MITK_EXCEPTIONMACRO_H_DEFINED
#define MITK_EXCEPTIONMACRO_H_DEFINED

#include "mitkException.h"
#include <itkMacro.h>
#include <mitkLogMacros.h>

/** The exception macro is used to print error information / throw an exception 
 *  (i.e., usually a condition that results in program failure). 
 *
 *  Example usage looks like:
 *  mitkExceptionMacro("this is error info");
 */
#define mitkExceptionMacro(messagetext) {mitkSpecializedExceptionMacro(messagetext,mitk::Exception);}

/** The specialized exception macro is used to print error information / throw exceptions 
  * in cases of specialized errors. This means the second parameter must be a class which 
  * inherits from mitk::Exception. An object of this exception is thrown when using the macro.
  * Thus, more differentiated excaptions can be thrown, when needed.
  *
  * Example usage:
  * mitkSpecializedExceptionMacro("this is error info",mitk::MySpecializedException); 
  */
#define mitkSpecializedExceptionMacro(messagetext,classname) \
  { \
  ::itk::OStringStream message; \
  message << "mitk::EXCEPTION: " \
  << "(Object:" << this->GetNameOfClass() << "(" << this << ")" << "/File:" << __FILE__ << "/Line:" << __LINE__ << "): " messagetext; \
  MITK_DEBUG << message.str().c_str(); /* Print a MITK debug message to log exceptions in debug mode. */ \
  throw classname(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION); /* Explicit naming to work around Intel compiler bug.  */ \
  }
  
#endif
{'fraction_non_alphanumeric': 0.17822265625, 'fraction_numerical': 0.0, 'mean_word_length': 4.827880512091038, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5814804', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1121, 'n_words': 365}