feisty meow concerns codebase 2.140
guards.cpp
Go to the documentation of this file.
1
2// Name : guards
3// Author : Chris Koeritz
5// Copyright (c) 1989-$now By Author. This program is free software; you can
6// redistribute it and/or modify it under the terms of the GNU General Public
7// License as published by the Free Software Foundation:
8// http://www.gnu.org/licenses/gpl.html
9// or under the terms of the GNU Library license:
10// http://www.gnu.org/licenses/lgpl.html
11// at your preference. Those licenses describe your legal rights to this
12// software, and no other rights or warranties apply.
13// Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
15
16#include "astring.h"
17#include "guards.h"
18
19namespace basis {
20
21void format_error(const base_string &class_name, const base_string &func_name,
22 const base_string &error_message, base_string &to_fill)
23{
24 astring to_return = class_name;
25 to_return += "::";
26 to_return += func_name;
27 to_return += ": ";
28 to_return += error_message;
29 to_fill = to_return;
30}
31
32void throw_error(const base_string &class_name, const base_string &func_name,
33 const base_string &error_message)
34{
35 astring to_throw;
36 format_error(class_name, func_name, error_message, to_throw);
37 throw to_throw;
38}
39
40void throw_error(const astring &class_name, const astring &func_name,
41 const astring &error_message)
42{
43 throw_error((base_string &)class_name, (base_string &)func_name, (base_string &)error_message);
44}
45
46} //namespace.
47
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
Defines the base class for all string processing objects in hoople.
Definition base_string.h:28
The guards collection helps in testing preconditions and reporting errors.
Definition array.h:30
void throw_error(const base_string &class_name, const base_string &func_name, const base_string &error_message)
throws an error that incorporates the class name and function name.
Definition guards.cpp:32
void format_error(const base_string &class_name, const base_string &func_name, const base_string &error_message, base_string &to_fill)
writes a string "to_fill" in a nicely formatted manner using the class and function names.
Definition guards.cpp:21