-
Notifications
You must be signed in to change notification settings - Fork 0
/
fitsiochecker.cpp
39 lines (34 loc) · 1.1 KB
/
fitsiochecker.cpp
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
#include "fitsiochecker.h"
#include <fitsio.h>
#include <sstream>
#include <stdexcept>
void FitsIOChecker::checkStatus(int status, const std::string& filename)
{
if(status) {
/* fits_get_errstatus returns at most 30 characters */
char err_text[31];
fits_get_errstatus(status, err_text);
char err_msg[81];
std::stringstream errMsg;
errMsg << "CFITSIO reported error when performing IO on file '" << filename << "':" << err_text << " (";
while(fits_read_errmsg(err_msg))
errMsg << err_msg;
errMsg << ')';
throw std::runtime_error(errMsg.str());
}
}
void FitsIOChecker::checkStatus(int status, const std::string& filename, const std::string& operation)
{
if(status) {
/* fits_get_errstatus returns at most 30 characters */
char err_text[31];
fits_get_errstatus(status, err_text);
char err_msg[81];
std::stringstream errMsg;
errMsg << "During operation " << operation << ", CFITSIO reported error when performing IO on file '" << filename << "': " << err_text << " (";
while(fits_read_errmsg(err_msg))
errMsg << err_msg;
errMsg << ')';
throw std::runtime_error(errMsg.str());
}
}