CppTools
Loading...
Searching...
No Matches
ErrorHandler.hpp
Go to the documentation of this file.
1
11#ifndef CPP_TOOLS_ERROR_HANDLER_HPP
12#define CPP_TOOLS_ERROR_HANDLER_HPP
13
14#include <iostream>
15#include <fstream>
16
17#include "OutputColor.hpp"
18
20namespace CppTools
21{
23 const std::string ERROR_PROMPT = COLOR_RED + " ERROR: " + COLOR_WHITE;
25 const std::string WARNING_PROMPT = COLOR_MAGENTA + " WARNING: " + COLOR_RESET;
27 const std::string INFO_PROMPT = " [ " + COLOR_GREEN + "INFO" + COLOR_RESET + " ] ";
28
33 void PrintError(const std::string& message, const bool exitProgram = true);
37 void PrintWarning(const std::string& message);
41 bool FileExists(const std::string& name);
48 bool CheckInputFile(const std::string& name, const bool closeAfterFail = true);
56 void CheckOutputFile(const std::string& name, const bool closeAfterFail = true,
57 const std::ios_base::openmode openmode = std::ios::out);
58}
59#endif /* CPP_TOOLS_ERROR_HANDLER_HPP */
const std::string INFO_PROMPT
String containing green text "INFO".
Definition ErrorHandler.hpp:27
const std::string WARNING_PROMPT
String containing magenta text "WARNING".
Definition ErrorHandler.hpp:25
bool CheckInputFile(const std::string &name, const bool closeAfterFail=true)
Checks whether the file exists or not If files exists the function does nothing, else it prints error...
Definition ErrorHandler.cpp:40
bool FileExists(const std::string &name)
Returns true if the file exists, else false.
Definition ErrorHandler.cpp:27
void PrintWarning(const std::string &message)
Prints warning prompt.
Definition ErrorHandler.cpp:22
void PrintError(const std::string &message, const bool exitProgram=true)
Prints error prompt.
Definition ErrorHandler.cpp:16
void CheckOutputFile(const std::string &name, const bool closeAfterFail=true, const std::ios_base::openmode openmode=std::ios::out)
Checks whether the file can be created If files exists the function does nothing, else it prints erro...
Definition ErrorHandler.cpp:51
const std::string ERROR_PROMPT
String containing red text "ERROR".
Definition ErrorHandler.hpp:23
Contains aliases for colors to use in output in terminal.
const std::string COLOR_MAGENTA
magenta text
Definition OutputColor.hpp:30
const std::string COLOR_RED
red text
Definition OutputColor.hpp:22
const std::string COLOR_WHITE
white text
Definition OutputColor.hpp:34
const std::string COLOR_RESET
default color in terminal (aka white)
Definition OutputColor.hpp:18
const std::string COLOR_GREEN
green text
Definition OutputColor.hpp:24