タグ

errorに関するkyokomiのブックマーク (2)

  • HTTP APIの詳細なエラー情報をレスポンスに持たせるための仕様

    今日では HTTP(s) で API が公開されることは当たり前の時代ですが、エラーをアプリケーションにどう伝えるかは、個々の API の設計に依存していました。特に、HTTP ステータスコードは有限であり、元々持っている意味があるので、自由に使うことはできません。API はそのドメインごとにもっと複雑で細かなエラー情報があるはずで、それらはレスポンスボディに載せてアプリケーションに伝えることになりますが、その書式に規定は今までありませんでした。 HTTP API にて、アプリケーションにエラー情報を伝達するための(レスポンスボディに載せられる)標準的な形式が、RFC7807 Problem Details for HTTP APIs で定められています。適用例としては、以下のようになります。 HTTP/1.1 403 Forbidden Content-Type: application

  • Errors are values - The Go Programming Language

    Rob Pike 12 January 2015 A common point of discussion among Go programmers, especially those new to the language, is how to handle errors. The conversation often turns into a lament at the number of times the sequence if err != nil { return err } shows up. We recently scanned all the open source projects we could find and discovered that this snippet occurs only once per page or two, less often th

    Errors are values - The Go Programming Language
  • 1