Added error handling.
This commit is contained in:
parent
f1657f1ffd
commit
47271ae5ff
@ -39,6 +39,7 @@ include_directories(
|
|||||||
SYSTEM OPENDHT_INCLUDE_DIRS)
|
SYSTEM OPENDHT_INCLUDE_DIRS)
|
||||||
|
|
||||||
set(SRCS
|
set(SRCS
|
||||||
|
src/error.cpp
|
||||||
src/node.cpp)
|
src/node.cpp)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wpedantic -Werror -Wfatal-errors -pedantic-errors -fno-elide-constructors")
|
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wpedantic -Werror -Wfatal-errors -pedantic-errors -fno-elide-constructors")
|
||||||
|
33
src/error.cpp
Normal file
33
src/error.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
||||||
|
* Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "neocomm.h"
|
||||||
|
#include "error.hpp"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
static std::vector<std::string> errors;
|
||||||
|
|
||||||
|
void add_error(std::string error) {
|
||||||
|
if(not errors.empty())
|
||||||
|
errors.push_back(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *NeoComm_get_last_error() {
|
||||||
|
return errors.back().c_str();
|
||||||
|
}
|
23
src/error.hpp
Normal file
23
src/error.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
||||||
|
* Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
void add_error(std::string error);
|
Loading…
Reference in New Issue
Block a user