Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add break; for each switch case #133

Closed
godmonth opened this issue Jun 27, 2024 · 2 comments
Closed

add break; for each switch case #133

godmonth opened this issue Jun 27, 2024 · 2 comments

Comments

@godmonth
Copy link

https://github.com/tronprotocol/trident/blob/main/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java

add break; for each case

private String resolveResultCode(int code) {
    String responseCode = "";
    switch (code) {
        case 0:
            responseCode = "SUCCESS";
            break;
        case 1:
            responseCode = "SIGERROR";
            break;
        case 2:
            responseCode = "CONTRACT_VALIDATE_ERROR";
            break;
        case 3:
            responseCode = "CONTRACT_EXE_ERROR";
            break;
        case 4:
            responseCode = "BANDWITH_ERROR";
            break;
        case 5:
            responseCode = "DUP_TRANSACTION_ERROR";
            break;
        case 6:
            responseCode = "TAPOS_ERROR";
            break;
        case 7:
            responseCode = "TOO_BIG_TRANSACTION_ERROR";
            break;
        case 8:
            responseCode = "TRANSACTION_EXPIRATION_ERROR";
            break;
        case 9:
            responseCode = "SERVER_BUSY";
            break;
        case 10:
            responseCode = "NO_CONNECTION";
            break;
        case 11:
            responseCode = "NOT_ENOUGH_EFFECTIVE_CONNECTION";
            break;
        case 20:
            responseCode = "OTHER_ERROR";
            break;
    }
    return responseCode;
}
@angrynurd
Copy link
Contributor

https://github.com/tronprotocol/trident/blob/main/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java

add break; for each case

private String resolveResultCode(int code) {
    String responseCode = "";
    switch (code) {
        case 0:
            responseCode = "SUCCESS";
            break;
        case 1:
            responseCode = "SIGERROR";
            break;
        case 2:
            responseCode = "CONTRACT_VALIDATE_ERROR";
            break;
        case 3:
            responseCode = "CONTRACT_EXE_ERROR";
            break;
        case 4:
            responseCode = "BANDWITH_ERROR";
            break;
        case 5:
            responseCode = "DUP_TRANSACTION_ERROR";
            break;
        case 6:
            responseCode = "TAPOS_ERROR";
            break;
        case 7:
            responseCode = "TOO_BIG_TRANSACTION_ERROR";
            break;
        case 8:
            responseCode = "TRANSACTION_EXPIRATION_ERROR";
            break;
        case 9:
            responseCode = "SERVER_BUSY";
            break;
        case 10:
            responseCode = "NO_CONNECTION";
            break;
        case 11:
            responseCode = "NOT_ENOUGH_EFFECTIVE_CONNECTION";
            break;
        case 20:
            responseCode = "OTHER_ERROR";
            break;
    }
    return responseCode;
}

hi, @godmonth
really appreciate your comment.
the original code without the break statements is buggy,which will execute later branches till the end. Obviously, this is useless;
may fix it in the later release;

@angrynurd angrynurd mentioned this issue Oct 9, 2024
@angrynurd
Copy link
Contributor

angrynurd commented Oct 10, 2024

fixed in version 0.9.1 .

@lvs007 lvs007 closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants