LCOV - code coverage report
Current view: top level - advgetopt - exception.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 12 100.0 %
Date: 2021-08-20 21:57:12 Functions: 13 19 68.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * License:
       3             :  *    Copyright (c) 2006-2021  Made to Order Software Corp.  All Rights Reserved
       4             :  *
       5             :  *    https://snapwebsites.org/project/advgetopt
       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        5468 : DECLARE_LOGIC_ERROR(getopt_logic_error);
      49             : 
      50             : 
      51             : // generic getopt exception
      52             : //
      53          34 : 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          14 : DECLARE_EXCEPTION(getopt_exception, getopt_initialization);
      62             : 
      63             : 
      64             : 
      65             : 
      66             : // the process is viewed as done, exit now
      67           4 : class getopt_exit
      68             :     : public getopt_exception
      69             : {
      70             : public:
      71           4 :     getopt_exit(std::string const & msg, int code)
      72           4 :         : getopt_exception(msg)
      73           4 :         , f_code(code)
      74             :     {
      75           4 :     }
      76             : 
      77           4 :     int code() const
      78             :     {
      79           4 :         return f_code;
      80             :     }
      81             : 
      82             : private:
      83             :     int             f_code;
      84             : };
      85             : 
      86             : 
      87             : 
      88             : 
      89             : } // namespace advgetopt
      90             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13