File: error.cpp

package info (click to toggle)
kdebase 2%3A980312-8
  • links: PTS
  • area: contrib
  • in suites: hamm
  • size: 16,500 kB
  • ctags: 11,017
  • sloc: cpp: 77,278; ansic: 14,050; makefile: 2,643; sh: 2,151; perl: 844
file content (49 lines) | stat: -rw-r--r-- 877 bytes parent folder | download
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
// Error management class
//
// contains error status and last error
//
// Copyright (C) Martin R. Jones 1995
//

#include <stdlib.h>
#include <iostream.h>
#include "error.h"

cError Error;
#include <klocale.h>
#include <kapp.h>

// ============================================================================
// The default error handler
//
void DefHandler(int type, const char *theMsg)
{
	if (type == ERR_FATAL)
	{
		cout << klocale->translate("Fatal Error: ") << theMsg << endl;
		exit(1);
	}
	else
	{
		cout << klocale->translate("Warning: ") << theMsg << endl;
	}
}

// ============================================================================
//
cError::cError()
{
	SetHandler(DefHandler);
	type = ERR_NONE;
}

void cError::Set(int theType, const char *theDesc)
{
	type = theType;
	desc = theDesc;

	handler(type, desc);

	if (type == ERR_WARNING) type = ERR_NONE;
}