<commit_before>//----------------------------  exceptions.cc  ---------------------------
//    $Id$
//    Version: $Name$
//
//    Copyright (C) 1998, 1999, 2000, 2001, 2002 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//----------------------------  exceptions.cc  ---------------------------


#include <base/exceptions.h>
#include <string>
#include <cstdlib>
#include <iostream>

#ifdef HAVE_STD_STRINGSTREAM
#  include <sstream>
#else
#  include <strstream>
#endif



ExceptionBase::ExceptionBase () :
		file(""), line(0), function(""), cond(""), exc("")
{};



ExceptionBase::ExceptionBase (const char* f, const int l, const char *func,
			      const char* c, const char *e) :
		file(f), line(l), function(func), cond(c), exc(e)
{};



ExceptionBase::~ExceptionBase () throw ()
{};



void ExceptionBase::SetFields (const char* f,
			       const int l,
			       const char *func,
			       const char *c,
			       const char *e)
{
  file = f;
  line = l;
  function = func;
  cond = c;
  exc  = e;
};



void ExceptionBase::PrintExcData (std::ostream &out) const
{
  out << "An error occurred in line <" << line
      << "> of file <" << file
      << "> in function" << std::endl
      << "    " << function << std::endl
      << "The violated condition was: "<< std::endl
      << "    " << cond << std::endl
      << "The name and call sequence of the exception was:" << std::endl
      << "    " << exc  << std::endl
      << "Additional Information: " << std::endl;
};



void ExceptionBase::PrintInfo (std::ostream &out) const
{
  out << "(none)" << std::endl;
};



const char * ExceptionBase::what () const throw ()
{
				   // have a place where to store the
				   // description of the exception as a char *
				   //
				   // this thing obviously is not multi-threading
				   // safe, but we don't care about that for now
				   //
				   // we need to make this object static, since
				   // we want to return the data stored in it
				   // and therefore need a liftime which is
				   // longer than the execution time of this
				   // function
  static std::string description;
				   // convert the messages printed by the
				   // exceptions into a std::string
#ifdef HAVE_STD_STRINGSTREAM
  std::ostringstream converter;
#else
  std::ostrstream converter;
#endif

  converter << "--------------------------------------------------------"
	    << std::endl;
				   // put general info into the std::string
  PrintExcData (converter);
				   // put in exception specific data
  PrintInfo (converter);
  
  converter << "--------------------------------------------------------"
	    << std::endl;
#ifndef HAVE_STD_STRINGSTREAM
  converter << std::ends;
#endif

  description = converter.str();

  return description.c_str();
};



namespace deal_II_exceptions
{

  std::string additional_assert_output;
<commit_msg>If we promise we don't throw an exception in a function, then make pretty damn sure we don't.<commit_after>//----------------------------  exceptions.cc  ---------------------------
//    $Id$
//    Version: $Name$
//
//    Copyright (C) 1998, 1999, 2000, 2001, 2002 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//----------------------------  exceptions.cc  ---------------------------


#include <base/exceptions.h>
#include <string>
#include <cstdlib>
#include <iostream>

#ifdef HAVE_STD_STRINGSTREAM
#  include <sstream>
#else
#  include <strstream>
#endif



ExceptionBase::ExceptionBase () :
		file(""), line(0), function(""), cond(""), exc("")
{};



ExceptionBase::ExceptionBase (const char* f, const int l, const char *func,
			      const char* c, const char *e) :
		file(f), line(l), function(func), cond(c), exc(e)
{};



ExceptionBase::~ExceptionBase () throw ()
{};



void ExceptionBase::SetFields (const char* f,
			       const int l,
			       const char *func,
			       const char *c,
			       const char *e)
{
  file = f;
  line = l;
  function = func;
  cond = c;
  exc  = e;
};



void ExceptionBase::PrintExcData (std::ostream &out) const
{
  out << "An error occurred in line <" << line
      << "> of file <" << file
      << "> in function" << std::endl
      << "    " << function << std::endl
      << "The violated condition was: "<< std::endl
      << "    " << cond << std::endl
      << "The name and call sequence of the exception was:" << std::endl
      << "    " << exc  << std::endl
      << "Additional Information: " << std::endl;
};



void ExceptionBase::PrintInfo (std::ostream &out) const
{
  out << "(none)" << std::endl;
};



const char * ExceptionBase::what () const throw ()
{
                                   // if we say that this function
                                   // does not throw exceptions, we
                                   // better make sure it does not
  try 
    {
                                       // have a place where to store the
                                       // description of the exception as
                                       // a char *
                                       //
                                       // this thing obviously is not
                                       // multi-threading safe, but we
                                       // don't care about that for now
                                       //
                                       // we need to make this object
                                       // static, since we want to return
                                       // the data stored in it and
                                       // therefore need a lifetime which
                                       // is longer than the execution
                                       // time of this function
      static std::string description;
                                       // convert the messages printed by
                                       // the exceptions into a
                                       // std::string
#ifdef HAVE_STD_STRINGSTREAM
      std::ostringstream converter;
#else
      std::ostrstream converter;
#endif

      converter << "--------------------------------------------------------"
                << std::endl;
                                       // put general info into the std::string
      PrintExcData (converter);
                                       // put in exception specific data
      PrintInfo (converter);
  
      converter << "--------------------------------------------------------"
                << std::endl;
#ifndef HAVE_STD_STRINGSTREAM
      converter << std::ends;
#endif

      description = converter.str();

      return description.c_str();
    }
  catch (std::exception &exc) 
    {
      std::cerr << "*** Exception encountered in exception handling routines ***"
                << std::endl
                << "*** Message is "   << std::endl
                << exc.what ()         << std::endl
                << "*** Aborting! ***" << std::endl;
      std::abort ();
      return 0;
    }
  catch (...)
    {
      std::cerr << "*** Exception encountered in exception handling routines ***"
                << std::endl
                << "*** Aborting! ***" << std::endl;
      std::abort ();
      return 0;
    }
};



namespace deal_II_exceptions
{

  std::string additional_assert_output;

{'fraction_non_alphanumeric': 0.17399766446087972, 'fraction_numerical': 0.005709095627351758, 'mean_word_length': 1.4752729608220938, 'pattern_counts': {'":': 0, '<': 155, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5608209', 'n_tokens_mistral': 2170, 'n_tokens_neox': 1929, 'n_words': 648}