<commit_before>from harpoon.errors import BadAmazon
from harpoon import VERSION

from botocore.exceptions import ClientError, NoCredentialsError
from input_algorithms.spec_base import NotSpecified
from six.moves.urllib.parse import urlparse
from contextlib import contextmanager
import logging
import base64
import boto3
import os

log = logging.getLogger("harpoon.amazon.iam")

@contextmanager
def catch_no_credentials(message, **info):
    """Turn a NoCredentialsError into a BadAmazon"""
    try:
        yield
    except NoCredentialsError as error:
        if hasattr(error, "response"):
            info['error_code'] = error.response["ResponseMetadata"]["HTTPStatusCode"]
            info['error_message'] = error.response["Error"]["Message"]
        else:
            info['error_message'] = error.message

        raise BadAmazon(message, **info)

@contextmanager
def catch_boto_400(message, **info):
    """Turn a BotoServerError 400 into a BadAmazon"""
    try:
        yield
    except ClientError as error:<commit_msg>Fix error message when no credentials<commit_after>from harpoon.errors import BadAmazon
from harpoon import VERSION

from botocore.exceptions import ClientError, NoCredentialsError
from input_algorithms.spec_base import NotSpecified
from six.moves.urllib.parse import urlparse
from contextlib import contextmanager
import logging
import base64
import boto3
import os

log = logging.getLogger("harpoon.amazon.iam")

@contextmanager
def catch_no_credentials(message, **info):
    """Turn a NoCredentialsError into a BadAmazon"""
    try:
        yield
    except NoCredentialsError as error:
        if hasattr(error, "response"):
            info['error_code'] = error.response["ResponseMetadata"]["HTTPStatusCode"]
            info['error_message'] = error.response["Error"]["Message"]
        else:
            info['error_message'] = error.fmt

        raise BadAmazon(message, **info)

@contextmanager
def catch_boto_400(message, **info):
    """Turn a BotoServerError 400 into a BadAmazon"""
    try:
        yield
    except ClientError as error:
{'fraction_non_alphanumeric': 0.09029779058597502, 'fraction_numerical': 0.008645533141210375, 'mean_word_length': 4.105392156862745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1256171', 'n_tokens_mistral': 582, 'n_tokens_neox': 581, 'n_words': 166}