Helpful error status definitions
-
Obfuscated:
public class ObfuscatedClass {
protected static final int ERROR_CODE_0 = 0; // Completed successfully
protected static final int ERROR_CODE_1 = 1; // Error - unauthorized
protected static final int ERROR_CODE_2 = 2; // Error - invalid request
}
With these, you might as well just hardcode instead of use the definitions.
-
Is the class literally obfuscated, as in using an obfuscation tool? In which case, preserving the actual names of the constants would be not-obfuscation.
-
@pkmnfrk said:
Is the class literally obfuscated, as in using an obfuscation tool? In which case, preserving the actual names of the constants would be not-obfuscation.
No, sorry, I should have been explicit: I just obfuscated it for the purpose of posting.
-
Yes, obviously they should have used named constants, like so:
public class ObfuscatedClass {
See? Much better.protected static final int ERROR_CODE_0 = ERR_CODE_SUCCESS; // Completed successfully
protected static final int ERROR_CODE_1 = ERR_CODE_AUTH; // Error - unauthorized
protected static final int ERROR_CODE_2 = ERR_CODE_INVALID_REQ; // Error - invalid request
}
-
@JoeCool said:
Obfuscated:
public class ObfuscatedClass {
protected static final int ERROR_CODE_0 = 0; // Completed successfully
protected static final int ERROR_CODE_1 = 1; // Error - unauthorized
protected static final int ERROR_CODE_2 = 2; // Error - invalid request
}
With these, you might as well just hardcode instead of use the definitions.What is missing is:
static readonly string [] ERROR_CODES = new string[] {"Completed successfully", "Error - unauthorized", "Error - invalid request"}; static readonly int [] ERROR_CODES_SUCCESS = new int[] {0}; static readonly int [] ERROR_CODES_ERRORS = new int[] {1,2};