You can't have error codes? I have never seen anything saying that you can't. (If there is something I have missed, feel free to cite it.)
Of course you can have things go wrong. Things actually do. But when they do, it has to not crash - neither the software nor the plane.
You got a malformed packet from some other system? You'd better not use it like it's valid, and you'd better not crash. Returning an error code to say "that packet wasn't valid" is a perfectly valid way to deal with it.
The engine fell off the plane? You'd better not be trying to respond to the sensor readings from that engine any more, because they are by definition garbage.
Sure, for each individual thing, try as hard as possible to make it so that it cannot go wrong. But that won't be possible for everything. For the rest, make it so that it can go wrong and you still have a flyable plane and running software.
Do you know what happened the last time a plane dropped packets it thought were invalid? Nobody noticed and it just kept receiving them until it (by chance) decided one was valid, and then an A330 full of people suddenly plummeted towards the ground, causing 12 serious and 107 minor injuries. Thankfully it was able to recover before it hit the ground, and land at the nearest suitable airport. https://en.wikipedia.org/wiki/Qantas_Flight_72