Basically you edit exception.hh and define your exception like so
DEFINE_DGTYPE_EXCEPT(Invalid_input)
Then you can throw it like so
throw dgtype::Invalid_input_exception("Munchkin-rsa")
When caught, if you call the function what() like so
catch (dgtype::Exception e) {
std::cerr << e.what() << std::endl;
}
It will print:
Munchkin-rsa: Invalid_input_exception
<dgtype/dgtype.hh>
or <dgtype/exception.hh>
to use it; preferrably the latter, but dgtype.hh
should include all of our types for you
#pragma not even once
__DEFINING_EXCEPTIONS
a gcc extension?
make clean-force; make all; make -k test-all
make install-openssl
kdw0134@build stego-attack-lib $ gcc stego-attack-lib.cc -o stego-attack-lib -lcrypt -w
/tmp/ccmMzbzc.o: In function `getMD5Hash(char*, unsigned char*, bool)':
stego-attack-lib.cc:(.text+0x15f): undefined reference to `MD5'
collect2: error: ld returned 1 exit status
make clean-force; make all; make -k test-all
======================================
Starting Debug Build
======================================
-- The C compiler identification is AppleClang 6.1.0.6020049
-- The CXX compiler identification is AppleClang 6.1.0.6020049
-- Check for working C compiler: /usr/local/opt/ccache/libexec/cc
-- Check for working C compiler: /usr/local/opt/ccache/libexec/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/opt/ccache/libexec/c++
-- Check for working CXX compiler: /usr/local/opt/ccache/libexec/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- GMP libs: /usr/local/lib/libgmp.dylib /usr/local/lib/libgmpxx.dylib
-- Found GMP: /usr/local/include
-- Found OpenSSL: /usr/lib/libssl.dylib;/usr/lib/libcrypto.dylib (found version "0.9.8}")
Found rsa-crypt-lib. Adding dependency: rsa-crypt depends on rsa-crypt-lib
Found rsa-crypt-lib. Linking rsa-crypt with rsa-crypt-lib
Found rsa-attack-lib. Adding dependency: rsa-attack depends on rsa-attack-lib
Found rsa-attack-lib. Linking rsa-attack with rsa-attack-lib
Found stego-crypt-lib. Adding dependency: stego-crypt depends on stego-crypt-lib
Found stego-crypt-lib. Linking stego-crypt with stego-crypt-lib
Found stego-attack-lib. Adding dependency: stego-attack depends on stego-attack-lib
Found stego-attack-lib. Linking stego-attack with stego-attack-lib
Coveralls: Using alternate CMake script dir: /Users/sam/Code/C++/CSCE315/Project4/DickGrayson/share/cmake
COVERALLS UPLOAD: ON
Found rsa-attack-lib. Linking rsa-attack-test with rsa-attack-lib
Found rsa-crypt-lib. Linking rsa-crypt-test with rsa-crypt-lib
Found stego-attack-lib. Linking stego-attack-test with stego-attack-lib
Found stego-crypt-lib. Linking stego-crypt-test with stego-crypt-lib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/sam/Code/C++/CSCE315/Project4/DickGrayson/debug
Scanning dependencies of target dgcrypto
Scanning dependencies of target dgtype
Scanning dependencies of target rsa-attack-lib
Scanning dependencies of target dgimg
Scanning dependencies of target dgsnd
Scanning dependencies of target rsa-crypt-lib
Scanning dependencies of target stego-attack-lib
Scanning dependencies of target stego-crypt-lib
[ 2%] Scanning dependencies of target gtest
[ 5%] [ 7%] [ 10%] [ 12%] [ 15%] [ 17%] Building CXX object lib/CMakeFiles/dgtype.dir/dgtype/dgtype.cc.o
[ 20%] Building CXX object lib/CMakeFiles/dgcrypto.dir/dgcrypto/dginteger.cc.o
[ 23%] Building CXX object lib/CMakeFiles/rsa-attack-lib.dir/rsa-attack-lib/common_modulus.cc.o
Building CXX object lib/CMakeFiles/stego-attack-lib.dir/stego-attack-lib/stego-attack-lib.cc.o
Building CXX object lib/CMakeFiles/dgsnd.dir/dgsnd/dgsnd.cc.o
Building CXX object lib/CMakeFiles/dgcrypto.dir/dgcrypto/dgrandominteger.cc.o
[ 25%] Building CXX object lib/CMakeFiles/dgsnd.dir/dgsnd/wav.cc.o
Building CXX object lib/CMakeFiles/rsa-attack-lib.dir/rsa-attack-lib/factorization_attack.cc.o
Building CXX object lib/CMakeFiles/dgcrypto.dir/dgcrypto/dgrandomprime.cc.o
[ 28%] Building CXX object lib/CMakeFiles/rsa-attack-lib.dir/rsa-attack-lib/known_totient.cc.o
[ 30%] Creating directories for 'gtest'
[ 35%] [ 35%] [ 38%] [ 41%] Building CXX object lib/CMakeFiles/rsa-crypt-lib.dir/rsa-crypt-lib/rsa-crypt-lib.cc.o
[ 43%] Building CXX object lib/CMakeFiles/stego-crypt-lib.dir/stego-crypt-lib/embedding_agent.cc.o
[ 46%] Building CXX object lib/CMakeFiles/stego-crypt-lib.dir/stego-crypt-lib/extracting_agent.cc.o
[ 48%] Building CXX object lib/CMakeFiles/dgimg.dir/dgimg/bmp_data.cc.o
Building CXX object lib/CMakeFiles/dgimg.dir/dgimg/bmp.cc.o
Building CXX object lib/CMakeFiles/dgimg.dir/dgimg/EasyBMP.cc.o
Building CXX object lib/
Linking CXX executable dgimg-test
CMakeFiles/dgsnd-test.dir/dgsnd/dgsnd-test.cc.o: In function `Wav_InvalidFormatException_Test::TestBody()':
dgsnd-test.cc:(.text+0xe6): undefined reference to `sf_close'
CMakeFiles/dgsnd-test.dir/dgsnd/dgsnd-test.cc.o: In function `Wav_InaccessibleFileException_Test::TestBody()':
dgsnd-test.cc:(.text+0x2c6): undefined reference to `sf_close'
CMakeFiles/dgsnd-test.dir/dgsnd/dgsnd-test.cc.o: In function `Wav_SampleSetMask_Test::TestBody()':
dgsnd-test.cc:(.text+0x5f2): undefined reference to `sf_close'
CMakeFiles/dgsnd-test.dir/dgsnd/dgsnd-test.cc.o: In function `Wav_SampleUnsetMask_Test::TestBody()':
dgsnd-test.cc:(.text+0xa02): undefined reference to `sf_close'
CMakeFiles/dgsnd-test.dir/dgsnd/dgsnd-test.cc.o: In function `DG::Sound::WAV::~WAV()':
dgsnd-test.cc:(.text._ZN2DG5Sound3WAVD2Ev[_ZN2DG5Sound3WAVD5Ev]+0x9): undefined reference to `sf_close'
../lib/libdgsnd.a(wav.cc.o): In function `DG::Sound::WAV::open(std::string const&)':
wav.cc:(.text+0x25): undefined reference to `sf_open'
collect2: error: ld returned 1 exit status
test/CMakeFiles/dgsnd-test.dir/build.make:94: recipe for target 'test/dgsnd-test' failed
make[3]: *** [test/dgsnd-test] Error 1