Added error handling functionality.

This commit is contained in:
Nicolás A. Ortega
2017-07-19 11:57:41 -05:00
parent 7aed5f8124
commit f70c9943c8
6 changed files with 126 additions and 14 deletions

27
include/neocomm/error.h Normal file
View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
#pragma once
/**
* @brief Return the error caused by the last function call.
*
* @return A string with the error.
*/
const char* NeoComm_get_last_error();

View File

@ -19,7 +19,9 @@
#pragma once
#include "nodes.h"
#include "neocomm/connection.h"
#include "neocomm/error.h"
#include "neocomm/nodes.h"
/**
* @file neocomm.h

View File

@ -54,8 +54,8 @@ struct NeoComm_node {
*
* @param max_nodes Maximum number of nodes available.
*
* @return If the operation failed then it will return 0, else it will
* return 1.
* @return If the operation failed then it will return 0 and you can read
* the error from the NeoComm_get_last_error function, else it will return 1.
*/
int NeoComm_init_nodes(unsigned int max_nodes);
@ -69,8 +69,8 @@ void NeoComm_shutdown_nodes();
*
* @param new_max_nodes New number of maximum nodes.
*
* @return If the new size is less than or equal to the current size, or
* the list failed to be reallocated, then it returns 0, else it returns 1.
* @return If the operation failed then it will return 0 and you can read
* the error from the NeoComm_get_last_error function, else it will return 1.
*/
int NeoComm_resize_node_list(unsigned int new_max_nodes);
@ -94,8 +94,9 @@ unsigned int NeoComm_get_node_count();
*
* @param addr Address of the new node.
*
* @return If the list is full then it will return NULL, else it will return
* a pointer to the new (or old, if already existing) node.
* @return If the operation failed then it will return NULL and you can
* read the error from the NeoComm_get_last_error function, else it will
* return 1.
*/
struct NeoComm_node *NeoComm_add_node(struct NeoComm_address addr);