Welcome to mirror list, hosted at ThFree Co, Russian Federation.

error.c « base « src - github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a53eff2069041a9e0b0a6ddcca6eb539cccb12b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
 * \file   error.c
 * \brief  Application-wide error reporting.
 * \author Copyright (c) 2007-2008 Jason Perkins and the Premake project
 */

#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "premake.h"
#include "error.h"

static char error_message[8192] = { 0 };


/**
 * Clear any existing error state.
 */
void error_clear(void)
{
	error_message[0] = 0;
}


/**
 * Returns the most recent error message set by error_set().
 * \returns The error message, or NULL if no error message has been set.
 */
const char* error_get(void)
{
	return (strlen(error_message) > 0) ? error_message : NULL;
}


/**
 * Set the description of an error condition, which may be retrieved with session_get_error().
 * The session uses a fixed length (around 8K) buffer for storing the error message, so make
 * sure the final size of the formatted message will fall under that limit.
 * \param   message A description of the error condition.
 */
void error_set(const char* message, ...)
{
	va_list args;

	assert(message);

	va_start(args, message);
	vsprintf(error_message, message, args);
	va_end(args);
}