mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 07:47:12 +02:00
new exceptions
This commit is contained in:
@ -2,20 +2,60 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "ClientSocket.h"
|
||||
#include "Timer.h"
|
||||
#include "logger.h"
|
||||
#include "slsDetector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include "Timer.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "sls_detector_funcs.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define VERBOSE
|
||||
|
||||
using sls::RuntimeError;
|
||||
using sls::SharedMemoryError;
|
||||
using sls::SocketError;
|
||||
|
||||
int main() {
|
||||
|
||||
//Catch exception
|
||||
try {
|
||||
throw RuntimeError("something went wrong");
|
||||
} catch (RuntimeError &e) {
|
||||
std::cout << "Caught RuntimeError with message : " << e.what() << '\n';
|
||||
}
|
||||
|
||||
//Catch base class
|
||||
try {
|
||||
throw SharedMemoryError("Could not create shared memory");
|
||||
} catch (RuntimeError &e) {
|
||||
std::cout << "Caught: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
//Catch base class after looking for something else
|
||||
try {
|
||||
throw SharedMemoryError("Could not create shared memory");
|
||||
} catch (SocketError &e) {
|
||||
|
||||
std::cout << "Caught Socket error: " << e.what() << '\n';
|
||||
|
||||
} catch (RuntimeError &e) {
|
||||
std::cout << "Caught base class: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
//Catch any after looking for something else
|
||||
try {
|
||||
throw SharedMemoryError("Could not create shared memory");
|
||||
} catch (SocketError &e) {
|
||||
|
||||
std::cout << "Caught Socket error: " << e.what() << '\n';
|
||||
|
||||
} catch (...) {
|
||||
std::cout << "Caught Something else probably should have let me crash\n";
|
||||
}
|
||||
|
||||
|
||||
throw RuntimeError("This one we missed");
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user