bump to -rc12
[gnucap-felix.git] / lib / io_error.cc
blobcf42bd8f16d63261b62fb2594a65885c11549a91
1 /*$Id: io_error.cc,v 1.1 2009-10-23 12:01:45 felix Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
22 * Error handler.
23 * Collection of functions to handle all types of errors
24 * including user interrupts, system errors, overflow, etc.
26 //testing=script,sparse 2006.07.17
27 #include "ap.h"
28 #include "u_opt.h"
29 /*--------------------------------------------------------------------------*/
30 void error(int,const char*,...);
31 void error(int,const std::string&);
32 /*--------------------------------------------------------------------------*/
33 #if 0
34 Exception_CS::Exception_CS(const std::string& Message, const CS& cmd, unsigned cursor)
35 :Exception(Message),
36 _cmd(cmd.fullstring()),
37 _cursor(cursor)
38 {untested();
40 #endif
41 /*--------------------------------------------------------------------------*/
42 Exception_CS::Exception_CS(const std::string& Message, const CS& cmd)
43 :Exception(Message),
44 _cmd(cmd.fullstring()),
45 _cursor(cmd.cursor())
48 /*--------------------------------------------------------------------------*/
49 const std::string Exception_CS::message()const
51 std::string s;
52 if (_cursor < 40) {
53 s = _cmd.substr(0,60)
54 + '\n' + std::string(_cursor, ' ') + "^ ? " + Exception::message();
55 }else{untested();
56 s = "... " + _cmd.substr(_cursor-36, 56)
57 + "\n ^ ? " + Exception::message();
59 return s;
61 /*--------------------------------------------------------------------------*/
62 /* error: error message printer
63 * print it, if severe enough
64 * terminate command, if really bad
66 void error(int badness, const char* fmt, ...)
68 if (badness >= OPT::picky) {
69 char buffer[BIGBUFLEN] = "";
70 va_list arg_ptr;
71 va_start(arg_ptr,fmt);
72 vsprintf(buffer,fmt,arg_ptr);
73 va_end(arg_ptr);
74 IO::error << buffer;
75 }else{
78 /*--------------------------------------------------------------------------*/
79 void error(int badness, const std::string& message)
81 if (badness >= OPT::picky) {
82 IO::error << message;
83 }else{
86 /*--------------------------------------------------------------------------*/
87 /*--------------------------------------------------------------------------*/
88 // vim:ts=8:sw=2:noet: