LCOV - code coverage report
Current view: top level - advgetopt - exception.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 11 100.0 %
Date: 2020-11-13 17:54:34 Functions: 11 16 68.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * License:
       3             :  *    Copyright (c) 2006-2019  Made to Order Software Corp.  All Rights Reserved
       4             :  *
       5             :  *    https://snapwebsites.org/
       6             :  *    contact@m2osw.com
       7             :  *
       8             :  *    This program is free software; you can redistribute it and/or modify
       9             :  *    it under the terms of the GNU General Public License as published by
      10             :  *    the Free Software Foundation; either version 2 of the License, or
      11             :  *    (at your option) any later version.
      12             :  *
      13             :  *    This program is distributed in the hope that it will be useful,
      14             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :  *    GNU General Public License for more details.
      17             :  *
      18             :  *    You should have received a copy of the GNU General Public License along
      19             :  *    with this program; if not, write to the Free Software Foundation, Inc.,
      20             :  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      21             :  *
      22             :  * Authors:
      23             :  *    Alexis Wilke   alexis@m2osw.com
      24             :  *    Doug Barbieri  doug@m2osw.com
      25             :  */
      26             : #pragma once
      27             : 
      28             : /** \file
      29             :  * \brief Definitions of the advanced getopt exceptions.
      30             :  *
      31             :  * The library generates exceptions which are defined here. These are
      32             :  * derived from the libexcept library so we get a stack trace whenever
      33             :  * an exception occurs.
      34             :  */
      35             : 
      36             : #include    <libexcept/exception.h>
      37             : 
      38             : 
      39             : 
      40             : 
      41             : namespace advgetopt
      42             : {
      43             : 
      44             : 
      45             : 
      46             : // generic logic error (something's wrong in the library)
      47             : //
      48        5464 : DECLARE_LOGIC_ERROR(getopt_logic_error);
      49             : 
      50             : 
      51             : // generic getopt exception
      52             : //
      53          20 : DECLARE_MAIN_EXCEPTION(getopt_exception);
      54             : 
      55             : 
      56             : // problem with a default argument
      57             : //
      58             : DECLARE_EXCEPTION(getopt_exception, getopt_invalid_default);
      59           8 : DECLARE_EXCEPTION(getopt_exception, getopt_undefined);
      60           4 : DECLARE_EXCEPTION(getopt_exception, getopt_invalid);
      61             : DECLARE_EXCEPTION(getopt_exception, getopt_initialization);
      62             : 
      63             : 
      64             : 
      65             : 
      66             : // the process is viewed as done, exit now
      67           4 : class getopt_exit : public getopt_exception
      68             : {
      69             : public:
      70           4 :     getopt_exit(std::string const & msg, int code)
      71           4 :         : getopt_exception(msg)
      72           4 :         , f_code(code)
      73             :     {
      74           4 :     }
      75             : 
      76           4 :     int code() const
      77             :     {
      78           4 :         return f_code;
      79             :     }
      80             : 
      81             : private:
      82             :     int             f_code;
      83             : };
      84             : 
      85             : 
      86             : 
      87             : 
      88             : } // namespace advgetopt
      89             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13