Classify error types in a more reliable way.

The previous way we classify errors is not reliable -- check a particular
string in error messages returned from AWS. This commit changes to check
error code and error name.