The root cause is a very common bug: treating no response as an empty response. It's usually caused by missing or bad error handling. Some libraries and RPC APIs make it impossible to differentiate between the two cases.
I've recently learned a lot of Rust. Rust's std::result::Result type [1] helps avoid this error. I think it is superior to the error handling facilities in other languages:
- C: errno, boolean return values, `null`
- C++: exceptions, errno, boolean return values, `null`; std::expected<T,E> is being developed
I've recently learned a lot of Rust. Rust's std::result::Result type [1] helps avoid this error. I think it is superior to the error handling facilities in other languages:
- C: errno, boolean return values, `null`
- C++: exceptions, errno, boolean return values, `null`; std::expected<T,E> is being developed
- Java: exceptions, `null`, Optional<T>
- Golang: `nil`, `error`, `if err != nil { return nil, err }` boilerplate
- Javascript: `undefined`, exceptions, futures
- Python: exceptions, `None`, boolean return values
- Swift: exceptions, `nil`, `try?`, optional values
- Dart: exceptions, futures, `null`
Would it be worthwhile to create Result-like error handling libraries for the major languages?
[1]: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-wi...