Skip to content

400 errors do not return enough useful information to debug. #183

@mgmonteleone

Description

@mgmonteleone

This needs to ensure that the full error message from the API is returned,

Otherwise it is very difficult to debug 400 errors.

class ErrAtlasBadRequest(ErrAtlasGeneric):
    """Atlas : Bad Request
    Constructor
    Args:
        c (int): HTTP code
        details (dict): Response payload
    """

    def __init__(self, c, details):

        if details.get('errorCode', None) == 'DUPLICATE_CLUSTER_NAME':
            raise (ErrAtlasDuplicateClusterName(c, details))
        if details.get('errorCode', None) == 'RESOURCE_NOT_FOUND_FOR_JOB':
            raise (ErrAtlasJobError(c, details))
        if details.get('errorCode', None) == 'CANNOT_CANCEL_AUTOMATED_RESTORE':
            raise (ErrAtlasBackupError(c,details))
        if details.get('errorCode', None) in ['ATLAS_MAINTENANCE_ALREADY_SCHEDULED',
                                              'ATLAS_NUM_MAINTENANCE_DEFERRALS_EXCEEDED']:
            raise (ErrMaintenanceError(c,details))
        else:
            logger.critical(f"A generic error was raised")
            logger.critical(details)


        super().__init__("Something was wrong with the client request.", c, details)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions