<commit_before>/* 
 *  Copyright 2011 <NAME>
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef STROMX_CORE_EXCEPTION_H
#define STROMX_CORE_EXCEPTION_H

#include <exception>
#include <string>
#include "Config.h"

namespace stromx
{
    namespace core
    {
        class Data;
        
        /** \brief Abstract stromx exception. */
        class Exception : public std::exception
        {
        public:
            /** Constructs an exception. */
            Exception(const std::string & message) : m_message(message) {}
            
            virtual ~Exception() throw() {}
            
            /** Returns a description of the exception. */
            virtual const char* what() const throw() { return m_message.c_str(); }
                        
        private:
            std::string m_message; 
        };  
        
        /** \brief A wrong argument was passed to a function. */
        class WrongArgument : public Exception
        {
        public:
            WrongArgument(const std::string & message = "WrongArgument")
              : Exception(message)
            {}
        };  
        
        /** \brief An object was identified by a wrong ID. */
        class WrongId : public WrongArgument
        {
        public:
            WrongId(const std::string & message = "WrongId")
              : WrongArgument(message)
            {}
        };  
        
        /** \brief The current state does not allow a specific operation. */
        class WrongState : public Exception
        {
        public:
            WrongState(const std::string & message = "WrongState")
              : Exception(message)
            {}
        };
        
        /** \brief An internal, unexpected error occurred. */
        class InternalError : public Exception
        {
        public:
            InternalError(const std::string & message = "InternalError")
              : Exception(message)
            {}
        };
        
        /** \brief The current thread was stopped. */
        class Interrupt : public Exception
        {
        public:
            Interrupt(const std::string & message = "Interrupt")
            : Exception(message)
            {}
        };
        
        /** \brief A file related exception. */
        class FileException : public Exception
        {
        public:
            void setContainer(const std::string & container) { m_container = container; }
            
        protected:
            FileException(const std::string & filename, const std::string & container, 
                          const std::string & message)
              : Exception(message),
                m_filename(filename),
                m_container(container)
            {}
            
            virtual ~FileException() throw() {}
            
        private:
            const std::string m_filename;
            std::string m_container;
        };
        
        /** \brief An error occurred during file access. */
        class FileAccessFailed : public FileException
        {
        public:
            FileAccessFailed(const std::string & filename,
                             const std::string & message)
              : FileException(filename, "", message)
            {}
            
            FileAccessFailed(const std::string & filename,
                             const std::string & container,
                             const std::string & message)
              : FileException(filename, container, message)<commit_msg>Added accessor functions to exceptions<commit_after>/* 
 *  Copyright 2011 <NAME>
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef STROMX_CORE_EXCEPTION_H
#define STROMX_CORE_EXCEPTION_H

#include <exception>
#include <string>
#include "Config.h"

namespace stromx
{
    namespace core
    {
        class Data;
        
        /** \brief Abstract stromx exception. */
        class Exception : public std::exception
        {
        public:
            /** Constructs an exception. */
            Exception(const std::string & message) : m_message(message) {}
            
            virtual ~Exception() throw() {}
            
            /** Returns a description of the exception. */
            virtual const char* what() const throw() { return m_message.c_str(); }
                        
        private:
            std::string m_message; 
        };  
        
        /** \brief A wrong argument was passed to a function. */
        class WrongArgument : public Exception
        {
        public:
            WrongArgument(const std::string & message = "WrongArgument")
              : Exception(message)
            {}
        };  
        
        /** \brief An object was identified by a wrong ID. */
        class WrongId : public WrongArgument
        {
        public:
            WrongId(const std::string & message = "WrongId")
              : WrongArgument(message)
            {}
        };  
        
        /** \brief The current state does not allow a specific operation. */
        class WrongState : public Exception
        {
        public:
            WrongState(const std::string & message = "WrongState")
              : Exception(message)
            {}
        };
        
        /** \brief An internal, unexpected error occurred. */
        class InternalError : public Exception
        {
        public:
            InternalError(const std::string & message = "InternalError")
              : Exception(message)
            {}
        };
        
        /** \brief The current thread was stopped. */
        class Interrupt : public Exception
        {
        public:
            Interrupt(const std::string & message = "Interrupt")
            : Exception(message)
            {}
        };
        
        /** \brief A file related exception. */
        class FileException : public Exception
        {
        public:
            void setContainer(const std::string & container) { m_container = container; }
            
        protected:
            FileException(const std::string & filename, const std::string & container, 
                          const std::string & message)
              : Exception(message),
                m_filename(filename),
                m_container(container)
            {}
            
            virtual ~FileException() throw() {}
            
            const std::string filename() const { return m_filename; }
            const std::string container() const { return m_container; }
            
        private:
            const std::string m_filename;
            std::string m_container;
        };
        
        /** \brief An error occurred during file access. */
        class FileAccessFailed : public FileException
        {
        public:
            FileAccessFailed(const std::string & filename,
                             const std::string & message)
              : FileException(filename, "", message)
            {}
            
            FileAccessFailed(const std::string & filename,
                             const std::string & container,
                             const std::string & message)
              : FileException(filename, container, message)
{'fraction_non_alphanumeric': 0.08689320388349514, 'fraction_numerical': 0.001941747572815534, 'mean_word_length': 1.5720973782771535, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7356430', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1890, 'n_words': 603}