Consider that within a few minutes of his final problem with Moriarty, he'd come up with and begun to implement a plan for dealing with the rest of the Professor's organization -- a plan that required the world to believe that he'd suffered a failure almost as serious as this one.
He's Sherlock Holmes. He's the man Batman wants to be when he grows up. He is that damn good or he's not Sherlock Holmes. This is not to say that he's infallible; were that the case, the name Irene Adler would mean nothing to anyone. He errs. But I find it much more plausible that this is another case where his apparent error is voluntary and the opening of a door to perception.