Tidy up Klipper a bit
This MR aims to tidy up Klipper a little bit.
None of the changes are especially significant, but they hopefully make the codebase of a slightly higher standard (by not blindly assuming that certain operations succeed) and make debugging a bit easier (by improving error messages).
This is effectively the first stage (just tidying up) of the much larger MR !2502 - hopefully if this goes through, we can then start looking at the next block of commits, which will actually improve Klipper's performance in some cases.