Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Rasmus Larsson
Rasmus Larsson

Posted on

     

Error Handling Responsibility Principles

Principle 1

The code closest to the source of the error is responsible forproviding as much detail about the error and if possibleclassifying it if such is needed.

Motivation: The further you get from the error the harder this becomes.

Principle 2

Code further up in the call stack is responsible fordeciding on how to act on the error given the current context.

Motivation: Called code has no idea of the context.

Example

A DB error is thrown. The code closest to the error classifies it as a socket time out. This is bubbled up in the call stack which then decides to not retry because a user has decided that the query is no longer relevant.

Special Note

These principles apply not only within an in-memory call stack but also across e.g. micro-service boundaries.

Do you disagree? I would love your input.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Fullstack developer, in a previous life I lived and breathed EAI.
  • Location
    EU
  • Education
    University
  • Work
    Developer at https://www.tiqqe.com
  • Joined

More fromRasmus Larsson

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp