3 ms·
> They do this because if your server code makes a mistake This is neither good or best practice. My take: - Know that there are simple-mistake panics, and i
by kubanczyk 4y ago
> They do this because if your server code makes a mistake
This is neither good or best practice.
My take:
- Know that there are simple-mistake panics, and internal-state-just-went-bonkers panics. For the latter, you can guess the boundary of impact (one request, one connection, one job, one userID, one process, ...) but exit(1) is much more reliable than guessing.
- Tests can easily catch simple mistakes like accessing a nil pointer.
- Know that the kind of programmer who does not care about simple tests, will also not care about concurrency bugs which introduce the more dangerous types of state corruption. This corruption would likely be not limited to a single request.
Good luck to frameworks who assume that nothing bad would happen if they ignore a panic and continue serving more requests.
- heywhatupboys 4y ago> - Tests can easily catch simple mistakes like accessing a nil pointer. no they can't . this is exactly what is hard to test for, complex state that can occur by some combination of many variables on many values
- lawrjone 4y agoRespectfully, this is a really bad take. And one that flies in the face of the Go stdlib, given the default HTTP server will catch panics for you by default.