[Fixes #80402898] Refactor error handling