Skip to content

Instantly share code, notes, and snippets.

@mightyhorst
Last active January 25, 2019 00:14
Show Gist options
  • Select an option

  • Save mightyhorst/5c79774f06242daeb4c7f22d82dc731e to your computer and use it in GitHub Desktop.

Select an option

Save mightyhorst/5c79774f06242daeb4c7f22d82dc731e to your computer and use it in GitHub Desktop.
Error Handling
### Error flow
try
retry
on succeeded write operation add to rollback/undo log
catch
error code swicth case
send back Error Model:
code: 500
urn: io.kitset.{entity}
key: validation.{field}
name: Title
msg: Message
trace: Error stack (optional)
client has the same case on error catch
attempt rollback
rollback failed
retry
cloud watch - alert
cloud watch alert failed
retry
add to logs
rollback succeeded
send back to client
update client toast
eg. Controller.method = req, res, next
try
Service.method(attr)
rollback.prepend('info', Service.oppositeOfMethod)
catch(err)
next(err)
## compile
Syntax errors: errors due to the fact that the syntax of the language is not respected.
Semantic errors: errors due to an improper use of program statements.
Logical errors: errors due to the fact that the specification is not respected.
## run time errors
dynamic semantic errors, and logical errors, that cannot be detected by the compiler (debugging).
this can be handled with asserts (unit tests)
wrong type
variable/object doesnt exist
object doesnt have method
method expected to return type of
object attributes expected to be of type
## validation
property type
property not set
property doesnt exist
property not valid
json validation - nested object has object has object check
## database/model
inherits validation
relationship doesnt exist
relationship validation - nested model has model has model through join
null errors
- empty set
- relationship empty - eg. no children for user
column doesnt exist
wrong type - trying to write the wrong type
not unique
cant delete - proptected
## http
route doesnt exist
validation of header (exists, type, regex)
validation of body
access control/CORS
method not supported
## request - server to another server
## authn/authz
not authenticated
not authorized
not paid?
user removed or blocked?
## platforms
http server not responding
database/cache not responding
## rollback
rollback id, name, action
attempted rollback failed
## debug/production
env file missing
env file malformed
env doesnt have attribute
env attribute is not valid
warning: should be in debug mode
## timeout
async doesnt return
too long
unknown error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment