def merge_dicts(first, second):
    """Merges two dictionaries and errors if keys are the same."""
    for key in first:
        if key in second:
            raise KeyError('Matching keys in dicts trying to be merged.')

    merged = first.copy()
    merged.update(second)
    return merged