error.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include <iostream>
22 #include <stdlib.h>
23 
24 #include "error.hpp"
25 #include "streams.hpp"
26 
27 
29 
30 
31 pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber )
32 {
33 
34  errorStream<<"\n>>> Fatal error in phasicFlow\n" <<
35  "Error occured in source file "<< redText(fileName) <<
36  " at line "<<redText(linNumber)<<'\n';
37  return errorStream;
38 
39 }
40 
41 pFlow::iOstream& fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber )
42 {
43 
44  errorStream<<"\n>>> Fatal error in phasicFlow\n" <<
45  " Error is issued in function " << redText(fnName)<<
46  ", located in file "<< redText(fileName) <<
47  " at line "<< redText(linNumber) << '\n';
48  return errorStream;
49 }
50 
51 pFlow::iOstream& notImplementedErrorMessage(const char*fnName, const char* fileName, int lineNumber)
52 {
53 
54  errorStream<<"\n>>> Fatal error in phasicFlow\n";
55  errorStream<<" Function "<< redText(fnName) << " has not implmented yet!\n" <<
56  " Function definition is in source file "<< redText(fileName) <<
57  " at line "<< redText(lineNumber) <<'\n';
58  return errorStream;
59 }
60 
61 
62 pFlow::iOstream& ioErrorMessage(const char* fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber)
63 {
64 
65  errorStream<<"\n>>> Fatal IO file error\n"<<
66  " IO error at number "<<redText(fileLineNumber)<<
67  " of file " << redText(fileName)<<'\n';
68  errorStream<<" IO operation is peformed from function "<<redText(fnName) <<
69  " in file "<< redText(fName)<< " at line "<< redText(lNumber) <<'\n';
70  return errorStream;
71 }
72 
73 pFlow::iOstream& ioErrorMessage(const pFlow::word& fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber)
74 {
75  return ioErrorMessage( fileName.c_str(), fileLineNumber, fnName, fName, lNumber);
76 }
77 
78 
79 pFlow::iOstream& warningMessage(const char* fnName, const char* fileName, int linNumber )
80 {
81 
82  errorStream<<"\n>>> Warning in phasicFlow\n"<<
83  " Warning is issued in function " << yellowText(fnName)<<
84  " in source file "<< yellowText(fileName) <<
85  " at line "<< yellowText(linNumber) <<'\n';
86  return errorStream;
87 }
88 
90 {
91  errorStream<<"\n>>> phasicFlow is exiting . . ." << pFlow::endl;
92  exit(EXIT_FAILURE);
93  return errorStream;
94 }
95 
96 
errorStream
static pFlow::Ostream & errorStream
Definition: error.cpp:28
redText
#define redText(text)
Definition: streams.hpp:29
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
fatalErrorInMessage
pFlow::iOstream & fatalErrorInMessage(const char *fnName, const char *fileName, int linNumber)
Definition: error.cpp:41
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
warningMessage
pFlow::iOstream & warningMessage(const char *fnName, const char *fileName, int linNumber)
Definition: error.cpp:79
notImplementedErrorMessage
pFlow::iOstream & notImplementedErrorMessage(const char *fnName, const char *fileName, int lineNumber)
Definition: error.cpp:51
fatalErrorMessage
pFlow::iOstream & fatalErrorMessage(const char *fileName, int linNumber)
Definition: error.cpp:31
reportAndExit
pFlow::iOstream & reportAndExit()
Definition: error.cpp:89
ioErrorMessage
pFlow::iOstream & ioErrorMessage(const char *fileName, int fileLineNumber, const char *fnName, const char *fName, int lNumber)
Definition: error.cpp:62
pFlow::errReport
Ostream errReport
streams.hpp
yellowText
#define yellowText(text)
Definition: streams.hpp:30
pFlow::Ostream
Definition: Ostream.hpp:35
pFlow::iOstream
Definition: iOstream.hpp:53
error.hpp