<commit_before>//
// Bareflank Hypervisor
//
// Copyright (C) 2015 Assured Information Security, Inc.
// Author: <NAME>        <<EMAIL>>
// Author: <NAME>  <<EMAIL>>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#ifndef EXCEPTION_H
#define EXCEPTION_H

#include <string>
#include <ostream>
#include <typeinfo>
#include <stdexcept>

namespace bfn
{

// -----------------------------------------------------------------------------
// General Exception
// -----------------------------------------------------------------------------

/// The following defines a general exception used in Bareflank. This should
/// not thrown and instead, an exception that inherits from this should be
/// thrown that provides more decent output. This exception type can however
/// be inherited from, and caught. There are two main reasons why this exception
/// is used instead of using std::exception directly:
///
/// - std::exception uses 'what()' to provide information about what was thrown
///   which returns a const char *. In most cases, it's almost impossible to
///   return something using const char * without constructing a string, which
///   can be dangerous. More importantly, if the risk is ok, it's a pain (
///   for example, imagine returning an integer). Instead, we use a stream
///   operator, which is more likely to succeed (still has issues though), but
///   at least it's simple to use.
///
/// - Having a different type than std::exception gives us a simple means to
///   detect when the execption is something that we defined, vs something that
///   came from the STL.
///
class general_exception : public std::exception
{
public:

    /// Default Constructor
    ///
    general_exception() noexcept = default;

    /// Destructor
    ///
    ~general_exception() override = default;

    /// What<commit_msg>exception.h: Fixed minor issues in API DOC Signed-off-by: “Rico <“<EMAIL>”><commit_after>//
// Bareflank Hypervisor
//
// Copyright (C) 2015 Assured Information Security, Inc.
// Author: <NAME>        <<EMAIL>>
// Author: <NAME>  <<EMAIL>>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#ifndef EXCEPTION_H
#define EXCEPTION_H

#include <string>
#include <ostream>
#include <typeinfo>
#include <stdexcept>

namespace bfn
{

// -----------------------------------------------------------------------------
// General Exception
// -----------------------------------------------------------------------------

/// The following defines a general exception used in Bareflank. This should
/// not be thrown and instead, an exception that inherits from this should be
/// thrown that provides more decent output. This exception type can however
/// be inherited from, and caught. There are two main reasons why this exception
/// is used instead of using std::exception directly:
///
/// - std::exception uses 'what()' to provide information about what was thrown
///   which returns a const char *. In most cases, it's almost impossible to
///   return something using const char * without constructing a string, which
///   can be dangerous. More importantly, if the risk is ok, it's a pain (
///   for example, imagine returning an integer). Instead, we use a stream
///   operator, which is more likely to succeed (still has issues though), but
///   at least it's simple to use.
///
/// - Having a different type than std::exception gives us a simple means to
///   detect when the exception is something that we defined, vs something that
///   came from the STL.
///
class general_exception : public std::exception
{
public:

    /// Default Constructor
    ///
    general_exception() noexcept = default;

    /// Destructor
    ///
    ~general_exception() override = default;

    /// What
{'fraction_non_alphanumeric': 0.15137883825542733, 'fraction_numerical': 0.006649716409153139, 'mean_word_length': 2.5075445816186557, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4359078', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1208, 'n_words': 647}