Classify error types in a more reliable way.

Hello @nicks, 

Please review the following commits I made in branch 'xiao-more-reliable-error-classification'.

5692315dd9ebc63cbd68728309efda61bc504587 (2013-11-22 23:28:44 -0800)

Classify error types in a more reliable way.

The previou way we classify errors is not reliable -- check a particular
string in error message. This commit changes to check error code and
error name.

Check list:


R=@nicks