Join Slack
Powered by
Is it better to use require, assert and check func...
# announcements
c
Chilli
04/29/2020, 4:00 PM
Is it better to use require, assert and check functions or to just throw exceptions/errors myself?
s
Shawn
04/29/2020, 4:08 PM
use require and check, they’re (imo) much more concise
Shawn
04/29/2020, 4:08 PM
assert is a weird one if you’re not familiar with assertions on the jvm
c
Chilli
04/29/2020, 4:09 PM
Should I pass some throwables to them, so it's clear what happened or is the message string enough?
s
Shawn
04/29/2020, 4:28 PM
if you have throwables, then you should include them, but if you can’t handle that case, maybe it’d be worth it to just let the exception bubble up
Shawn
04/29/2020, 4:29 PM
specifically if you’re, for example, calling
error
to “handle” an exception
Shawn
04/29/2020, 4:29 PM
at that point you just ought to rethrow (or just not catch the exception in the first place)
💯 1
Open in Slack
Previous
Next