lean2/src/library/parser_nested_exception.h
Leonardo de Moura ccb9faf065 refactor(*): error messages
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-13 16:54:21 -08:00

25 lines
1.1 KiB
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <memory>
#include "util/exception.h"
#include "kernel/pos_info_provider.h"
namespace lean {
/** \brief Lean exception occurred when parsing file. */
class parser_nested_exception : public exception {
std::shared_ptr<exception> m_exception;
std::shared_ptr<pos_info_provider> m_provider;
public:
parser_nested_exception(std::shared_ptr<exception> const & ex, std::shared_ptr<pos_info_provider> const & pr):exception("parser exception"), m_exception(ex), m_provider(pr) {}
virtual ~parser_nested_exception() {}
virtual exception * clone() const { return new parser_nested_exception(m_exception, m_provider); }
virtual void rethrow() const { throw *this; }
virtual char const * what() const noexcept { return m_exception->what(); }
exception const & get_exception() const { return *(m_exception.get()); }
pos_info_provider const & get_provider() const { return *(m_provider.get()); }
};
}