3 ms·
> but essentially never safe to communicate to the compiler the error types your function returns. It is safe as long as you don't write too much code for no r
by randomdata 3y ago
> but essentially never safe to communicate to the compiler the error types your function returns.
It is safe as long as you don't write too much code for no reason. The problem in the example is that DatabaseError needlessly defined an Error method. It serves no purpose other than to allow the issue to arise. Remove said method, which has no reason to exist, and the program will fail to compile.
> Its a real problem. People don't write perfect code.
Okay, sure. It is possible that a programmer may, for whatever reason, leave out entire blocks of logic that the program needs. Imagine not adding billing logic to your storefront software – I'm sure it has happened to someone before! Making interfaces more intuitive does not solve that problem, though.
- burnished 3y agoWhy are you complaining that this person wrote a clear and small example that demonstrates what they are talking about? It is painfully rude; a description and a couple lines of code that runs is the gold standard for starting a programming conversation.
- kubanczyk 3y ago> It is safe as long as you don't write too much code for no reason. var errConcrete *strconv.NumError = nil var err error = errConcrete err != nil // true Please fix this one.