You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
何番煎じかわかりませんが TypeScript でのエラーハンドリングについて考えてみたいと思います。 この記事で扱う TypeScript のバージョンは 4.3 です。 エラーを型安全に扱いたい TypeScript を書いていれば誰もが一度はぶつかる問題ではないでしょうか。 TypeScript では catch した例外は any として扱われます。 これは JavaScript の仕様上どんな値でも throw できてしまうため仕方のないことなのですが、せっかく型安全性を手に入れるために TypeScript を使っているのに any をハンドリングしなければならないのは苦痛です。 次のように例外を throw し得る関数 foo() のエラーハンドリングを考えてみます。 e は any なので、プロパティにアクセスしようにも危険性が伴います。 そこで型アノテーションを使用して
エラーハンドリングのベストプラクティスについて自分なりに少し調べてみました 各APIControllerでエラー検知とエラーレスポンスを書くのDRY違反してる エラーレスポンスは構造が統一できていないとクライアント側が死んでしまう Applicationで一律例外検知してエラー内容をハンドリングしたほうが楽 C#のASP.NET MVC5ではController毎に例外キャッチなどはせずApplicationで一律ハンドリングするので、 Railsにも同様の機能は提供されていると思う。 その方法を調べると同時にRailsにおけるベストプラクティスを知っておこうって思った。 Applicationで一律例外検知してハンドリングする方法 ApplicationController で rescue_from メソッドを使う 404や500は 専用Controller用意とroutes.rb更新
Promise Error Handling 約束されたエラー Promiseとエラーの基本 Promise内で起きた例外は自動でキャッチされる エラー処理は.catch(fn)で行う var promise = new Promise(function(){ throw new Error("例外"); }); promise.catch(function(error){ // 例外をキャッチできる }); よくある問題 .catch(fn) をしないとエラーログも出せない .catch(fn) をしわすれてエラーの握りつぶしが起きる = unhandled rejection (.catchをしてないpromise) 4.6. Promise.prototype.done とは何か? 現状のunhandled rejectionへの対応 unhandled rejectionが発生した
process.on('uncaughtException', (err) => { fs.writeSync(1, `Caught exception: ${err}\n`); }); どこにもキャッチされずにprocessまで来てしまったエラーをキャッチ。 NodeJSのデフォルト(上記のようにハンドリングしない場合)では、このようなエラーはスタックトレースに出力して終了。 リスナーの関数はerrだけ。 注意点 このハンドリングでエラーがcatchされた場合、処理を継続すべきではない。 完全に想定外の状態になっていることを意味しているので、ここから無理やり復帰しようとして更なるエラーが起きる可能性がある。 例えるなら「コンピュータのアップグレード時にコンセントを抜くようなもの」。その意は「10回中9回は問題ないかもしれないが、1回はシステム破壊が起きる」。 ハンドリング内の処理でさらに
Next.jsを実践投入するには、エラーハンドリングまわりも考えないといけません。関心事は、サイト独自のエラーページデザインであったり、Sentryなどでのエラー通知だと思います。 まずはNext.jsが用意しているエラーページを見ていきましょう。 本記事は公式ドキュメントのエラーハンドリングの項目を一部翻訳しています。 https://github.com/zeit/next.js#custom-error-handling エラーハンドリングのカスタマイズ Next.jsではデフォルトのエラーハンドリングページが用意されています。ステータスコードが404もしくは500のエラーをキャッチし、クライアントとサーバーサイドの両方でハンドリングされます。 もしデフォルトのエラーコンポーネントをオーバーライドしたいのなら、_error.jsというファイルをpagesフォルダーの中に定義しましょう
こんにちは、サーバーサイドエンジニアの竹若です。今回GraphQLにおけるエラーハンドリングを調査、Ruby on Railsとgraphql-rubyを使って実装する機会があったので、そこで得られた知見を共有させていただきたいと思います。(なお今回の実装はプロダクション環境には出ていません) GraphQLの仕様とプラクティス それではまず初めに、GraphQLが仕様に定めているレスポンスの返し方を見ていきましょう。 レスポンスのフォーマットに関するプラクティス GraphQLのプラクティスの1つに、レスポンスのhttp statusを200で統一し、レスポンスのerrorsキーにエラーの詳細な情報を持たせるというものがあります。 なぜならGraphQLではリクエストに複数のクエリを含めることができるからです。 https://www.graph.cool/docs/faq/api-ee
この記事は、弁護士ドットコム Advent Calendar 2019 - Qiita の11日目の記事です。 要約 DatadogでブラウザーのJSエラーの収集を始めた。 1日に発生するJSエラー数を、1/4まで削減することができた。 エラー発生検知が、数時間から15分以内になった。 サービスの課題 以前、Sentryを弁護士ドットコムサービスが稼働しているowned k8sの片隅で運用していたが、運用負荷が高く、廃止。 サーバーサイドの監視は、きちんとやっていましたが、フロントの監視がおざなりになってました。 一部のページでは、Google Tag Manager経由で自作エラー検知スクリプトを埋め込んでいました。しかし、エラーを、Google Analyticsにイベント通知しているが、情報が少なく、エラーが追えませんでした。 結果、JSやフロントエンドのエラーは検知できませんでした
The product is great and the customer service is fantastic as well. —Remi Silva, Blanktag 12% of pages load with errors. About 0% are reported by users. Every minute people are left frustrated by broken software. It doesn't have to be like this. CatchJS tracks any JavaScript error that happens on your site, and notifies you when new problems happen.
20180727追記 CORS対応が必要になりました asnokaze.hatenablog.com 20180703追記 ドキュメントはhttps://w3c.github.io/network-error-logging/ にが移されました 20180608追記 仕様上は、jsonの各値はハイフンではなく、アンダースコアを使用するようになります report-to => report_to max-age => max_age ... etc https://github.com/WICG/network-error-logging/commit/86c4d1c0fa4c5d5ca1d8bdcd9fa931e7e4ab65c2 こんな感じ nel: {"report_to": "network-errors", "max_age": 2592000, "include_subdomai
rake aborted! ExecJS::ProgramError: Unexpected token: punc (:) (line: 1, col: 10, pos: 10) Error at new JS_Parse_Error (<eval>:2359:10623) at js_error (<eval>:2359:10842) at croak (<eval>:2359:19086) at token_error (<eval>:2359:19223) at unexpected (<eval>:2359:19311) at semicolon (<eval>:2359:19784) at simple_statement (<eval>:2359:22580) at <eval>:2359:20274 at <eval>:2359:19957 at block_ (<eval
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く