討論:異常處理
異常處理屬於維基百科科技主題的基礎條目第五級。請勇於更新頁面以及改進條目。 本條目屬於下列維基專題範疇: |
|||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
In software部分的翻譯
編輯Kiniry also notes that "Language design only partially influences the use of exceptions, and consequently, the manner in which one handles partial and total failures during system execution. The other major influence is examples of use, typically in core libraries and code examples in technical books, magazine articles, and online discussion forums, and in an organization’s code standards."
Contemporary applications face many design challenges when considering exception handling strategies. Particularly in modern enterprise level applications, exceptions must often cross process boundaries and machine boundaries. Part of designing a solid exception handling strategy is recognizing when a process has failed to the point where it cannot be economically handled by the software portion of the process.
這兩段有點難理解
簡介部分
編輯原文中的這一塊(已刪除)
各種程式語言在處理異常方面具有非常顯著的不同點(錯誤檢測與異常處理區別在於:錯誤檢測是在正常的程序流中,處理不可預見問題的代碼,例如一個調用操作未能成功結束)。某些程式語言有這樣的函數:當輸入存在非法數據時不能被安全地調用,或者返回值不能與異常進行有效的區別。例如,C語言中的atoi函數(ASCII串到整數的轉換)在輸入非法時可以返回0。在這種情況下編程者需要另外進行錯誤檢測(可能通過某些輔助全局變量如C的errno),或進行輸入檢驗(如通過正則表達式),或者共同使用這兩種方法。
以及這一塊:(未翻譯)
Alternative approaches to exception handling in software are error checking, which maintains normal program flow with later explicit checks for contingencies reported using special return values or some auxiliary global variable such as C's errno or floating point status flags; or input validation to preemptively filter exceptional cases.
這兩塊覺得很奇怪。