We require both a pre-screen design exercise as well as several white-board exercises during the interviews. We'll also request a code sample if I can't find anything of theirs online.
I have found a strong correlation between the design exercise and how well they'll do within the white-board exercises. It also appears to correlate with their on-the-job performance as well.
Generally, I'll forgive a mistake or two within any of the exercises. We don't require compiled code for the design, but bonus points are definitely awarded if it's a complete, working program. Likewise, the white-boarding exercises give me insight into the candidate's mindset since I'm watching them while they sketch out their answer.
In your particular case, I would say listen to what the code is telling you about the candidate. By the time you see their solution, you've had a number of touch points with them: their resume; notes from HR on the phone screen; your notes from the phone interview; etc... If you think they're sloppy and the code they submitted is equally sloppy, consider that a red flag. Ask if your team can handle that level of quality coming on-board. Determine if that's something you can train out of the candidate.
Likewise, if the candidate has been otherwise stellar but you notice a "rookie" mistake or a corner-case not being covered, then consider proceeding with the interview process. If everything the candidate did was already perfect then they would be demanding a much higher salary. There needs to be opportunity within your team for the candidate to grow and learn to become a better programmer.
These types of exercises are just a data point in the overall process. As they require more effort, they can be more telling as a data point. But they aren't always a make or break type decision point. It's kind of like requirements gathering. The initial rounds are usually a bit murky and you have to keep imploring to get to the actual needs. Ultimately, the interview process is about identifying a match between the candidate's skills and your projects needs. Likewise there needs to be a match between the growth and learning opportunities your team presents and the candidate's interests.
In short, use their code project as part of your overall assessment of their skill level. Interviewing is like fuzzy logic - it's generally not a binary
down vote at this point, but the code exercise will sway the analog signal into the well defined regions of