4 ms·
Yeah it may be valid, barring careful consideration of the exact situation. My canonical example is a web server. In the context of handling a web request, nev
by ufmace 6y ago
Yeah it may be valid, barring careful consideration of the exact situation. My canonical example is a web server.
In the context of handling a web request, never unwrap, because a web server should never die no matter what kind of weird or crazy thing a client somewhere sends it. Check every error for everything in that context, always at the very least drop back to a code path that returns a 500 and keeps the server running.
In the context of server init though, unwrap is good. If anything in the server init process goes wrong, that means I as the developer / deployment engineer did something wrong. The server should then blow up to let me know that something is very wrong and needs fixing. The server definitely should not try to rattle to life anyways and run in some sort of degraded state where it can't handle requests correctly.
- richardwhiuk 6y agoUsually `.expect` is better, as you can explain the error.