-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmap_exception.cpp
More file actions
78 lines (70 loc) · 2.29 KB
/
map_exception.cpp
File metadata and controls
78 lines (70 loc) · 2.29 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* ============================================================================
The MapException class defines exceptions thrown by the skymap-related classes.
Written by Michael R. Greason, ADNET, 27 December 2006.
Broken out of 'skymap.h'. MRG, ADNET, 23 January 2007.
============================================================================ */
#include <stdio.h>
#include <string.h>
#include "map_exception.h"
/* ----------------------------------------------------------------------------
'MapException' is the class constructor.
Arguments:
code - The error code.
status - A status value associated with the exception. Defaults to 0.
comm - A comment associated with the error.
Returned:
N/A.
---------------------------------------------------------------------------- */
MapException::MapException (ErrCode code, int status, const char *comm)
{
code_ = code;
status_ = status;
comment_ = (comm == NULL) ? NULL : strdup(comm);
}
/* ----------------------------------------------------------------------------
'MapException' is the class constructor.
Arguments:
code - The error code.
status - A status value associated with the exception. Defaults to 0.
Returned:
N/A.
---------------------------------------------------------------------------- */
MapException::~MapException (void)
{
if (comment_ != NULL) delete [] comment_;
}
/* ----------------------------------------------------------------------------
'Message' returns an error message associated with the error code.
Arguments:
None.
Returned:
The error message. This is written to internal static storage---be sure
to do something with it before calling this function again.
---------------------------------------------------------------------------- */
const char* MapException::Message (void) const
{
static char msg[48];
switch (code_)
{
case Memory:
strcpy(msg, "Memory allocation error!");
break;
case Bounds:
strcpy(msg, "Map index out of bounds!");
break;
case Undefined:
strcpy(msg, "Undefined pixel property!");
break;
case InvalidType:
strcpy(msg, "Invalid pixel type!");
break;
case FITSError:
if (status_ != 0) sprintf(msg, "FITS I/O Error: %d", status_);
else strcpy(msg, "FITS I/O Error");
break;
default:
*msg = '\0';
break;
}
return msg;
}