From 46dd56f2b2f80c065ece01fde62f335ed47c5c0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?=
 <rafael.carre@savoirfairelinux.com>
Date: Thu, 28 Jul 2011 14:11:40 -0400
Subject: [PATCH] * #6547: AudioZrtp: use runtime exceptions

Also support custom exception strings
---
 sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp | 6 +++---
 sflphone-common/src/audio/audiortp/AudioZrtpSession.h   | 9 +++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp
index 23c79de4fd..04ed8e4268 100644
--- a/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp
+++ b/sflphone-common/src/audio/audiortp/AudioZrtpSession.cpp
@@ -101,7 +101,7 @@ void AudioZrtpSession::initializeZid (void)
 {
 
     if (_zidFilename.empty()) {
-        throw ZrtpZidException();
+        throw ZrtpZidException("zid filename empty");
     }
 
     std::string zidCompleteFilename;
@@ -131,12 +131,12 @@ void AudioZrtpSession::initializeZid (void)
 
     if (remove (zidCompleteFilename.c_str()) !=0) {
         _debug ("Failed to remove zid file because of: %s", strerror (errno));
-        throw ZrtpZidException();
+        throw ZrtpZidException("zid file deletion failed");
     }
 
     if (initialize (zidCompleteFilename.c_str()) < 0) {
         _debug ("ZRTP initialization failed");
-        throw ZrtpZidException();
+        throw ZrtpZidException("zid initialization failed");
     }
 
     return;
diff --git a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h
index 9d33c2065b..8236861cf1 100644
--- a/sflphone-common/src/audio/audiortp/AudioZrtpSession.h
+++ b/sflphone-common/src/audio/audiortp/AudioZrtpSession.h
@@ -31,6 +31,7 @@
 #define __SFL_AUDIO_ZRTP_SESSION_H__
 
 #include <cstddef>
+#include <stdexcept>
 
 using std::ptrdiff_t;
 #include <ccrtp/rtp.h>
@@ -46,11 +47,11 @@ class SIPCall;
 namespace sfl
 {
 
-class ZrtpZidException: public std::exception
+class ZrtpZidException: public std::runtime_error
 {
-        virtual const char* what() const throw() {
-            return "ZRTP ZID initialization failed.";
-        }
+    public:
+        ZrtpZidException (const std::string& str="") :
+            std::runtime_error("ZRTP ZID initialization failed." + str) {}
 };
 
 // class AudioZrtpSession : public ost::TimerPort, public ost::SymmetricZRTPSession, public AudioRtpRecordHandler
-- 
GitLab