CAudioError: revise exception string format and the concatenate logic
[platform/core/api/audio-io.git] / src / cpp / CAudioError.cpp
index 3cadc76..66024d8 100644 (file)
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <sstream>
 #include <dlog.h>
 #include "CAudioIODef.h"
 
@@ -28,13 +27,11 @@ using namespace tizen_media_audio;
 CAudioError::CAudioError(EError err, const char* msg, const char* file, const char* func, int line) :
     __mError(err),
     __mFullMsg(msg) {
-    char __mErrorMsg[MSG_LENGTH] = { 0, };
+    ostringstream stringStream;
 
-    snprintf(__mErrorMsg, MSG_LENGTH, "[%s|%s|%s(%d)|"
-              COLOR_CYAN   "%s"     COLOR_END "]",
-             __convertErrorToString(__mError), file, func, line, msg);
-
-    __mFullMsg = std::runtime_error{__mErrorMsg};
+    stringStream << "[ " << __convertErrorToString(__mError)
+                 << " | "<< file << ": " << func << "(" << line << ") | " << msg << " ]";
+    __mFullMsg = runtime_error{stringStream.str()};
 }
 
 const char *CAudioError::what() const noexcept {