You can’t anticipate everything in a complex system. You can write code which make mistakes obvious and help you fix them quickly. Good asserts are one such example.
What would be of concern is if your work is plagued by “sometimes errors” and inconsistencies that make it unclear whether it’s improving over time.