<commit_before>//
//  LuaException.h
//  LuaState
//
//  Created by <NAME> on 17/03/14.
//
//  See LICENSE and README.md files

#pragma once

#include <lua.hpp>

#include <stdexcept>
#include <iostream>
#include <string>

namespace lua {
    
    namespace stack {
        
        inline void dump (lua_State *L) {
            int top = lua_gettop(L);
            for (int i = 1; i <= top; i++) {  /* repeat for each level */
                int t = lua_type(L, i);
                switch (t) {
                    case LUA_TSTRING:  /* strings */
                        std::cout << '`' << lua_tostring(L, i) << '\'';
                        break;
                        
                    case LUA_TBOOLEAN:  /* booleans */
                        std::cout << (lua_toboolean(L, i) ? "true" : "false");
                        break;
                        
                    case LUA_TNUMBER:  /* numbers */
                        std::cout << lua_tonumber(L, i);
                        break;
                        
                    default:  /* other values */
                        std::cout << lua_typename(L, t);
                        break;
                        
                }
                std::cout << "  ";  /* put a separator */
            }
            std::cout << std::endl;  /* end the listing */
        }
        
    }

    class ExceptionBase : public std::exception
    {
        std::string m_message;

    public:
        explicit ExceptionBase(const std::string& msg)
            : std::exception{}
            , m_message{ msg }
        {
        }

        const char* what() const override final
        {
            return m_message.c_str();
        }
    };

    //////////////////////////////////////////////////////////////////////////////////////////////
    class LoadError : public ExceptionBase
    {
    public:
        explicit LoadError(lua_State* luaState)
            : ExceptionBase{ lua_tostring(luaState, -1) }
        {
            lua_pop(luaState, 1);
        }
    };
    
    //////////////////////////////////////////////////////////////////////////////////////////////
    class RuntimeError : public ExceptionBase<commit_msg>Use proper noexcept on ExceptionBase::what for GCC<commit_after>//
//  LuaException.h
//  LuaState
//
//  Created by <NAME> on 17/03/14.
//
//  See LICENSE and README.md files

#pragma once

#include <lua.hpp>

#include <stdexcept>
#include <iostream>
#include <string>

namespace lua {
    
    namespace stack {
        
        inline void dump (lua_State *L) {
            int top = lua_gettop(L);
            for (int i = 1; i <= top; i++) {  /* repeat for each level */
                int t = lua_type(L, i);
                switch (t) {
                    case LUA_TSTRING:  /* strings */
                        std::cout << '`' << lua_tostring(L, i) << '\'';
                        break;
                        
                    case LUA_TBOOLEAN:  /* booleans */
                        std::cout << (lua_toboolean(L, i) ? "true" : "false");
                        break;
                        
                    case LUA_TNUMBER:  /* numbers */
                        std::cout << lua_tonumber(L, i);
                        break;
                        
                    default:  /* other values */
                        std::cout << lua_typename(L, t);
                        break;
                        
                }
                std::cout << "  ";  /* put a separator */
            }
            std::cout << std::endl;  /* end the listing */
        }
        
    }

    class ExceptionBase : public std::exception
    {
        std::string m_message;

    public:
        explicit ExceptionBase(const std::string& msg)
            : std::exception{}
            , m_message{ msg }
        {
        }

        const char* what() const noexcept(noexcept(m_message.c_str())) override final
        {
            return m_message.c_str();
        }
    };

    //////////////////////////////////////////////////////////////////////////////////////////////
    class LoadError : public ExceptionBase
    {
    public:
        explicit LoadError(lua_State* luaState)
            : ExceptionBase{ lua_tostring(luaState, -1) }
        {
            lua_pop(luaState, 1);
        }
    };
    
    //////////////////////////////////////////////////////////////////////////////////////////////
    class RuntimeError : public ExceptionBase
{'fraction_non_alphanumeric': 0.18681808060565575, 'fraction_numerical': 0.004008016032064128, 'mean_word_length': 0.9270699270699271, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 13, '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': '3477061', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1120, 'n_words': 266}