在鈦坦那邊花了蠻多時間把產品架構面的 error handling 機制弄好,不再是到處 try/catch 只寫 log return false.
不再是無謂的 try/catch re-throw exception.
不再是 catch(ex) throw ex; 的該死寫法。甚至吃掉 exception 不做事的情況。
該記 log 的只在邊界層,透過 decorator/action filter/middleware 來封裝與加載。也不再有那種 log 只記到表層的 call stack 而沒記錄到 inner exception 真正的問題發生點。
該做 error handling 或附加 run time 的資訊,handle 完 re-throw 自定義的 custom business exception, 再交給 error handling 底層來觸發對應的 error handler。
在發現問題(例外)的第一時間點 throw exception 通知整個 process 發生了什麼問題。
整個 call stack 與方法簽章都是乾乾淨淨的「正常流程」,沒有不必要的 return true/false 來通知是否有異常,也沒有不必要的 error code Enum 來一路傳遞回呼叫端。
發生怎樣的異常,該決定怎樣的 error code/status code 通知呼叫端,是最後要回傳結果那一層的 error handle 職責與行為。
Error handling 本身就是一整門學問,能在企業等級產品架構裡面打好這段基礎,可以指數性降低 application design 的複雜度。
鈦坦的產品工程師扛霸子之一的 Jrting ,開始把這門知識整理成系列文了,希望能給大家一些幫助。
https://medium.com/@neokn/exception-%E6%80%8E%E9%BA%BC%E4%B8%9F%E6%89%8D%E4%B8%9F%E5%BE%97%E6%BA%96-a385bd27ed15
「enum false true」的推薦目錄:
- 關於enum false true 在 91 敏捷開發之路 Facebook 的最讚貼文
- 關於enum false true 在 [問題] enum Boolean {false, true}; - 看板C_and_CPP 的評價
- 關於enum false true 在 Easy C enum question - Stack Overflow 的評價
- 關於enum false true 在 How to use both boolean and string value in enum? #32192 的評價
- 關於enum false true 在 Java's Boolean class - why not an enum? 的評價
- 關於enum false true 在 枚举| 深入理解TypeScript 的評價
enum false true 在 How to use both boolean and string value in enum? #32192 的推薦與評價
Hi, When I write the code as bellow, export enum TableResponsiveType { NO = false, NORMAL = true, WHOLE = 'whole', } An error happens, ... ... <看更多>
enum false true 在 [問題] enum Boolean {false, true}; - 看板C_and_CPP 的推薦與評價
開發平台(Platform): (Ex: Win10, Linux, ...)
codeblocks + GNU GCC Compiler
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
GNU GCC Compiler
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
tc3 circle.cpp
tc3 graphics.h
tc3 point.h
問題(Question):
最近看到多年前的 tc3, 內部有 graphics.h
就用 codeblocks + GNU GCC Compiler 編譯
先打開 tc3 中的 example 中的 circle.cpp
並將 tc3 中的 graphic.h 複製到 MinGW 的 include 資料夾下
編譯 circle.cpp 時
會引用到 tc3 中的 point.h 檔案
編譯顯示 point.h 中的 enum Boolean {false, true}; 出現錯誤
錯誤訊息為
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
C:\tc3\EXAMPLES\point.h|8|error: expected identifier before 'false'|
C:\tc3\EXAMPLES\point.h|8|error: expected '}' before 'false'|
C:\tc3\EXAMPLES\point.h|8|error: expected unqualified-id before 'false'|
C:\tc3\EXAMPLES\point.h|8|error: expected declaration before '}' token|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
一直無法修正
有人知道原因嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.252.151.20 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1681957017.A.EFE.html
... <看更多>