2013-11-27 03:15:49 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
2013-11-27 22:57:33 +00:00
|
|
|
#include <string>
|
2013-11-27 03:15:49 +00:00
|
|
|
#include "util/exception.h"
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
/**
|
2013-11-27 22:57:33 +00:00
|
|
|
\brief Exception for wrapping errors produced by the Lua engine.
|
2013-11-27 03:15:49 +00:00
|
|
|
*/
|
|
|
|
class script_exception : public exception {
|
|
|
|
public:
|
|
|
|
enum class source { String, File, Unknown };
|
2013-11-27 22:57:33 +00:00
|
|
|
private:
|
|
|
|
source m_source;
|
|
|
|
std::string m_file; // if source == File, then this field contains the filename that triggered the error.
|
|
|
|
unsigned m_line; // line number
|
|
|
|
script_exception(source s, std::string f, unsigned l):m_source(s), m_file(f), m_line(l) {}
|
|
|
|
public:
|
|
|
|
script_exception(char const * lua_error);
|
|
|
|
virtual ~script_exception();
|
2013-11-27 03:15:49 +00:00
|
|
|
virtual char const * what() const noexcept;
|
2013-11-27 22:57:33 +00:00
|
|
|
virtual source get_source() const { return m_source; }
|
|
|
|
virtual char const * get_filename() const;
|
|
|
|
virtual unsigned get_line() const;
|
|
|
|
/** \brief Return error message without position information */
|
|
|
|
virtual char const * get_msg() const noexcept;
|
|
|
|
virtual exception * clone() const { return new script_exception(m_source, m_file, m_line); }
|
|
|
|
virtual void rethrow() const { throw *this; }
|
2013-11-27 03:15:49 +00:00
|
|
|
};
|
|
|
|
}
|