type category = | Usage | Configuration | Authentication | Authorization | Not_found | Conflict | Transport | Protocol | Consistency | External_tool | Internal type t = { category : category; code : string; message : string } let make ~category ~code ~message = { category; code; message } let category error = error.category let code error = error.code let message error = error.message let category_name = function | Usage -> "usage" | Configuration -> "configuration" | Authentication -> "authentication" | Authorization -> "authorization" | Not_found -> "not_found" | Conflict -> "conflict" | Transport -> "transport" | Protocol -> "protocol" | Consistency -> "consistency" | External_tool -> "external_tool" | Internal -> "internal" let exit_code error = match error.category with | Usage -> 2 | Configuration -> 3 | Authentication -> 5 | Authorization -> 6 | Not_found -> 4 | Conflict -> 11 | Transport -> 7 | Protocol -> 8 | Consistency -> 10 | External_tool -> 9 | Internal -> 70