// Copyright 2011 Google Inc.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728/// \file exceptions.hpp29/// Exception types raised by lutok.3031#if !defined(LUTOK_EXCEPTIONS_HPP)32#define LUTOK_EXCEPTIONS_HPP3334#include <stdexcept>35#include <string>3637namespace lutok {383940class state;414243/// Base exception for lua errors.44class error : public std::runtime_error {45public:46explicit error(const std::string&);47virtual ~error(void) throw();48};495051/// Exception for errors raised by the Lua API library.52class api_error : public error {53/// Name of the Lua C API function that caused the error.54std::string _api_function;5556public:57explicit api_error(const std::string&, const std::string&);58virtual ~api_error(void) throw();5960static api_error from_stack(state&, const std::string&);6162const std::string& api_function(void) const;63};646566/// File not found error.67class file_not_found_error : public error {68/// Name of the not-found file.69std::string _filename;7071public:72explicit file_not_found_error(const std::string&);73virtual ~file_not_found_error(void) throw();7475const std::string& filename(void) const;76};777879} // namespace lutok808182#endif // !defined(LUTOK_EXCEPTIONS_HPP)838485