Demo entry 2765014

Error codes

   

Submitted by anonymous on Sep 28, 2015 at 11:20
Language: Java. Code size: 4.3 kB.

public static String getGasSafeErrorMessageWithCode(Context context, int errorCode) {
        String error = null;
        switch (errorCode) {

            case 0:
            case 200: // OK – if the service completes and data is returned.
            case 201: // Created – if the service is a post and the request completes.
            case 204: // No Content – if the service completes but there is no data available.
            {
                error = null; // VALID
            }
            break;

            case 203:
            {
                error = "We were unable to verify the engineer was registered to undertake this area of work. Please contact us on 0330 123 1127 where one of our team will be able to assist you.";
            }
            break;

            case 110:
            {
                error = "We have been unable to verify the subcontract details you have provided. Please check the details and try again. If you continue to experience an issue please contact us on 0330 123 1127 where one of our team will be able to assist you.";
            }
            break;

            default:
                error = getErrorMessageWithCode(context, errorCode);
                if (!TextUtils.isEmpty(error) && error.equalsIgnoreCase(getDefaultMessage()))
                    error = "We are sorry we been unable to process your request at this time. Please contact us on 0330 123 1127 where one of our team will be able to assist you.";
                break;
        }
        return error;
    }

    private static String getDefaultMessage() {
        return  "Server error, please try again later.";
    }

    public static String getErrorMessageWithCode(Context context, int errorCode) {
        String error = null;
        switch (errorCode) {

            case 1:
            {
                error = "Claims Can Only Be Back Dated By Up To 6 Months";
            }
            break;

            case 2:
            {
                error = "Barcode Already Used";
            }
            break;

            case 3:
            {
                error = "Barcode Incorrect";
            }
            break;

            case 4:
            {
                error = "Application Key Incorrect";
            }
            break;

            case 5:
            {
                error = "Login Failed";
            }
            break;

            case 6:
            {
                error = "Incorrect login details, please try again";
            }
            break;

            case 7:
            {
                error = "Invalid Account";
            }
            break;

            case 8:
            {
                error = "Invalid Token";
            }
            break;

            case 0:
            case 200: // OK – if the service completes and data is returned.
            case 201: // Created – if the service is a post and the request completes.
            case 204: // No Content – if the service completes but there is no data available.
            {
                error = null; // VALID
            }
            break;

            case 401: // Unauthorised – if the service call could not be validated by the Application Key of the Session Token.
            {
                error = "Unauthorised access, please login and retry.";
            }
            break;

            case 403: // Session Token expired. (Valid for 6 months, but session will expire after 20 minutes of inactivity.)
            {
                DbManagerHelper.getInstance(context).getUserManager().deleteAll();
                error = "Your session has expired, please sign-in and try again.";
            }
            break;

            case 404: // Not found
            {
                error = "Server error, please try again later.";
            }
            break;

            case 500: // Internal Server Error.
            {
                error = "Server error, please try again later.";
            }
            break;

            default:
                error = getDefaultMessage();
                break;
        }
        return error;
    }

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).