[問題] 當程式因throw而死時能知道exception嗎?

作者: s4300026 (s4300026)   2018-11-07 19:56:08
開發平台(Platform): (Ex: Win10, Linux, ...)
win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
exception
問題(Question):
如題。 當C# throw 時,會有additional information 輔助除錯
會將 exception.ToString();
但是C++發生throw時,要怎麼做到這件事情呢?
餵入的資料(Input):
throw;
預期的正確結果(Expected Output):
https://imgur.com/H10oKg2
錯誤結果(Wrong Output):
https://imgur.com/7YDJ2ZP
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
C++:throw std::exception("Hello World!");
C#:throw new Exception("Hello World!");
補充說明(Supplement):
如果沒有辦法的話,想問大家是怎麼處理發生問題時,
沒接到問題造成程式死掉的bug。 應該說有建議的方法嗎?
作者: jerryh001   2018-11-07 23:45:00
VS的話我記得按繼續就會中斷在掛的那一行
作者: s4300026 (s4300026)   2018-11-08 15:44:00
因為我的程式會給別人使用,如果有漏給ini就不給報錯...
作者: hare1039 (hare1039)   2018-11-10 01:08:00
catch(std::exception e) std::cout << e.what() ?

Links booklink

Contact Us: admin [ a t ] ucptt.com