⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exception.hh

📁 hadoop:Nutch集群平台
💻 HH
字号:
/** * Copyright 2005 The Apache Software Foundation * * 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 EXCEPTION_HH#define EXCEPTION_HH#include <exception>#include <iostream>#include <string>namespace hadoop {  /**   * Parent-type for all exceptions in hadoop.   * Provides an application specified message to the user, a call stack from   * where the exception was created, and optionally an exception that caused    * this one.   */  class Exception: public std::exception {  public:    /**     * Create an exception.     * @param message The message to give to the user.     * @param reason The exception that caused the new exception.     */    explicit Exception(const std::string& message,                       const std::string& component="",                       const std::string& location="",                       const Exception* reason=NULL);    /**     * Copy the exception.     * Clones the reason, if there is one.     */    Exception(const Exception&);    virtual ~Exception() throw ();    /**     * Make a new copy of the given exception by dynamically allocating     * memory.     */    virtual Exception* clone() const;    /**     * Print all of the information about the exception.     */    virtual void print(std::ostream& stream=std::cerr) const;    /**     * Result of print() as a string.     */    virtual std::string toString() const;    /**     * Print the call stack where the exception was created.     */    virtual void printCallStack(std::ostream& stream=std::cerr) const;    const std::string& getMessage() const {      return mMessage;    }    const std::string& getComponent() const {      return mComponent;    }    const std::string& getLocation() const {      return mLocation;    }    const Exception* getReason() const {      return mReason;    }    /**     * Provide a body for the virtual from std::exception.     */    virtual const char* what() const throw () {      return mMessage.c_str();    }    virtual const char* getTypename() const;  private:    const static int sMaxCallStackDepth = 10;    const std::string mMessage;    const std::string mComponent;    const std::string mLocation;    int mCalls;    void* mCallStack[sMaxCallStackDepth];    const Exception* mReason;    // NOT IMPLEMENTED    std::exception& operator=(const std::exception& right) throw ();  };  class IOException: public Exception {  public:    IOException(const std::string& message,                const std::string& component="",                const std::string& location="",                const Exception* reason = NULL);    virtual IOException* clone() const;    virtual const char* getTypename() const;  };}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -