2004-02-29 00:50:05 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2004-03-24 07:39:24 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "stdafx.h"
|
|
|
|
#endif
|
2004-02-29 00:50:05 +00:00
|
|
|
|
2004-03-24 20:53:43 +00:00
|
|
|
#ifndef _WIN32
|
2004-03-24 21:00:52 +00:00
|
|
|
#include "cstdio"
|
2004-03-24 20:57:21 +00:00
|
|
|
#include "cstdlib"
|
2004-03-24 21:03:56 +00:00
|
|
|
#include "unistd.h"
|
2004-03-24 21:00:52 +00:00
|
|
|
using namespace std;
|
2004-03-24 20:53:43 +00:00
|
|
|
#endif
|
|
|
|
|
2004-03-24 07:39:24 +00:00
|
|
|
#include "exception.h"
|
2004-02-29 00:50:05 +00:00
|
|
|
#include "error_numbers.h"
|
|
|
|
|
|
|
|
|
2004-04-04 03:31:16 +00:00
|
|
|
const char* boinc_base_exception::ErrorType() {
|
|
|
|
return "BOINC Exception";
|
|
|
|
}
|
2004-02-29 00:50:05 +00:00
|
|
|
|
2004-04-04 03:31:16 +00:00
|
|
|
const char * boinc_base_exception::ErrorMessage() {
|
|
|
|
return "Unknown Exception";
|
|
|
|
}
|
2004-02-29 00:50:05 +00:00
|
|
|
|
2004-04-04 03:31:16 +00:00
|
|
|
long boinc_base_exception::ErrorValue() {
|
|
|
|
return -1;
|
|
|
|
}
|
2004-02-29 00:50:05 +00:00
|
|
|
|
2004-04-04 03:31:16 +00:00
|
|
|
const char * boinc_base_exception::what() {
|
2004-02-29 00:50:05 +00:00
|
|
|
m_strErrorBuffer.empty();
|
|
|
|
|
|
|
|
memset(m_szConversionBuffer, '\0', sizeof(m_szConversionBuffer));
|
2004-03-24 21:21:25 +00:00
|
|
|
snprintf(m_szConversionBuffer, sizeof(m_szConversionBuffer), "%ld", ErrorValue());
|
|
|
|
|
2004-02-29 00:50:05 +00:00
|
|
|
m_strErrorBuffer.append(ErrorType());
|
|
|
|
m_strErrorBuffer.append(" ");
|
|
|
|
m_strErrorBuffer.append(m_szConversionBuffer);
|
|
|
|
m_strErrorBuffer.append(" ");
|
|
|
|
m_strErrorBuffer.append(ErrorMessage());
|
|
|
|
|
|
|
|
m_strErrorBuffer.append("\n");
|
|
|
|
|
|
|
|
m_strErrorBuffer.append(m_strErrorData);
|
|
|
|
|
|
|
|
m_strErrorBuffer.append("\n");
|
|
|
|
|
|
|
|
m_strErrorBuffer.append("Filename: '");
|
|
|
|
m_strErrorBuffer.append(m_strFilename);
|
|
|
|
m_strErrorBuffer.append("'\n");
|
|
|
|
|
|
|
|
memset(m_szConversionBuffer, '\0', sizeof(m_szConversionBuffer));
|
2004-03-24 21:21:25 +00:00
|
|
|
snprintf(m_szConversionBuffer, sizeof(m_szConversionBuffer), "%ld", m_lLineNumber);
|
2004-02-29 00:50:05 +00:00
|
|
|
|
|
|
|
m_strErrorBuffer.append("Line: '");
|
|
|
|
m_strErrorBuffer.append(m_szConversionBuffer);
|
|
|
|
m_strErrorBuffer.append("'\n");
|
|
|
|
|
|
|
|
return m_strErrorBuffer.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// BOINC Base Runtime Exception Class Implementation
|
|
|
|
//
|
2004-04-04 03:31:16 +00:00
|
|
|
const char * boinc_runtime_base_exception::ErrorType() {
|
|
|
|
return "BOINC Runtime Exception";
|
|
|
|
}
|
2004-02-29 00:50:05 +00:00
|
|
|
|
2004-04-04 03:31:16 +00:00
|
|
|
const char * boinc_runtime_base_exception::ErrorMessage() {
|
|
|
|
return "Unknown Runtime Exception";
|
|
|
|
}
|
2004-02-29 00:50:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
// BOINC Runtime Exceptions
|
|
|
|
//
|
2004-04-04 03:31:16 +00:00
|
|
|
const char * boinc_out_of_memory_exception::ErrorMessage() {
|
|
|
|
return "Out Of Memory";
|
|
|
|
}
|
|
|
|
|
|
|
|
long boinc_out_of_memory_exception::ErrorValue() {
|
|
|
|
return ERR_MALLOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * boinc_invalid_parameter_exception::ErrorMessage() {
|
|
|
|
return "Invalid Parameter";
|
|
|
|
}
|
|
|
|
|
|
|
|
long boinc_invalid_parameter_exception::ErrorValue() {
|
|
|
|
return ERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char * boinc_file_operation_exception::ErrorMessage() {
|
|
|
|
return "File Operation Failure";
|
|
|
|
}
|
|
|
|
|
|
|
|
long boinc_file_operation_exception::ErrorValue() {
|
|
|
|
return ERR_FOPEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * boinc_signal_operation_exception::ErrorMessage() {
|
|
|
|
return "Signal Operation Failure";
|
|
|
|
}
|
|
|
|
|
|
|
|
long boinc_signal_operation_exception::ErrorValue() {
|
|
|
|
return ERR_SIGNAL_OP;
|
|
|
|
}
|