既存のエラー体系の収集
エラーに限らずステータスコードも集める。
検討のための参考情報であり、正確ではない。
原始的な boolean 値
成功失敗フラグ
table:success_fail
true 成功、success, succeeded
false 失敗、fail, failed
まず間違いようがない。
エラー有無フラグというパターンも考えられるが、ほぼ存在しない。
int 値によるエラー有無
様々なパターンがある。
大体の場合
負または-1の時にエラーとされる。
0または正の値の時に正常とされる。
-errno を返す事もある。(参考: systemd)
C言語の main 関数の返り値(または exit関数に渡す値)
#include <stdlib.h>
EXIT_SUCCESS 成功
EXIT_FAILURE 失敗
C言語の errno
errno
Java の例外
Java:例外
結果型方式
値かエラー情報かのどちらかを返す型
値の一部を流用するとか、別の返し口を作る(引数に返却用の参照を用意するとか)とかしなくてもよい。
Rust の Result<T, E>
Error で検索すると様々なエラー用の型が定義されている
https://doc.rust-lang.org/std/all.html?search=Error
Windows
Windows では複数種類のエラーコード体系がある。
システムエラーコード(Win32 API 関連で出てくる)
Error Codes https://docs.microsoft.com/ja-jp/windows/win32/debug/system-error-codes
HRESULT
https://en.wikipedia.org/wiki/HRESULT
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a?redirectedfrom=MSDN
システムエラーコードを包含させることができる。
Office VBA
エラーメッセージ https://docs.microsoft.com/ja-jp/office/vba/language/reference/error-messages
トラップ可能なエラー https://docs.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/trappable-errors
HTTPステータスコード
https://ja.wikipedia.org/wiki/HTTPステータスコード
https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
SMTPステータスコード
https://en.wikipedia.org/wiki/List_of_SMTP_server_return_codes
https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml
PostreSQL
SQLCODE
古いインターフェース
https://www.postgresql.jp/document/12/html/ecpg-errors.html
SQLSTATE
現在望ましいインターフェース
https://www.postgresql.jp/document/12/html/errcodes-appendix.html
MySQL
MySQL 8.0 Appendix B Error Messages and Common Problems https://dev.mysql.com/doc/refman/8.0/en/error-handling.html
MySQL 5.6 付録 B エラー、エラーコード、および一般的な問題 https://dev.mysql.com/doc/refman/5.6/ja/error-handling.html
Web API(HTTP)
RFC 7807 Problem Details for HTTP APIs
エラーコードではなくエラーの表現方法の定義
関連
エラーの分類