Page MenuHomec4science

exception.h
No OneTemporary

File Metadata

Created
Sun, Feb 23, 21:05

exception.h

//
// Created by Joachim Koerfer on 08.05.2019.
//
#ifndef EXCEPTION_H
#define EXCEPTION_H
#include <mpi.h>
#include <string>
#include <iostream>
#include <exception>
class FileOpenError: public std::exception {
private:
std::string msg_;
public:
FileOpenError(int MPI_Error, std::string file_name) {
char error_string[BUFSIZ];
int len_error, error_class;
MPI_Error_class(MPI_Error, &error_class);
MPI_Error_string(MPI_Error, error_string, &len_error);
msg_ = "Error when reading file '" + file_name + "'\n" + error_string + "\n";
}
virtual const char* what() const throw()
{
return msg_.c_str();
}
};
class FileWriteError: public std::exception {
private:
std::string msg_;
public:
FileWriteError(int MPI_Error, std::string file_name) {
char error_string[BUFSIZ];
int len_error, error_class;
MPI_Error_class(MPI_Error, &error_class);
MPI_Error_string(MPI_Error, error_string, &len_error);
msg_ = "Error when writing file '" + file_name + "'\n" + error_string + "\n";
}
virtual const char* what() const throw()
{
return msg_.c_str();
}
};
#endif

Event Timeline