diff --git a/CMakeLists.txt b/CMakeLists.txt index baec35f..a87920f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ include_directories( SYSTEM OPENDHT_INCLUDE_DIRS) set(SRCS + src/error.cpp src/node.cpp) set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wpedantic -Werror -Wfatal-errors -pedantic-errors -fno-elide-constructors") diff --git a/src/error.cpp b/src/error.cpp new file mode 100644 index 0000000..11fa671 --- /dev/null +++ b/src/error.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * 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 . + */ + +#include "neocomm.h" +#include "error.hpp" + +#include + +static std::vector 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(); +} diff --git a/src/error.hpp b/src/error.hpp new file mode 100644 index 0000000..8be0e4f --- /dev/null +++ b/src/error.hpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2017 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * 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 . + */ + +#pragma once + +#include + +void add_error(std::string error);