2
0

ErrorCode.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Feel free to copy/use it for your own project.
  3. * Keep in mind that it took me several days/weeks, beers and asperines to make this.
  4. * So be nice, and give me some credit, I won't bite and it won't hurt you.
  5. */
  6. import java.util.HashMap;
  7. /**
  8. *
  9. * @author Deben Oldert
  10. */
  11. public class ErrorCode {
  12. public String getCodeText(int id) {
  13. HashMap<Integer, String> list = new HashMap<>();
  14. /* Runtime errors */
  15. list.put(-1, "Unknown error code");
  16. list.put(0, "OK");
  17. list.put(1, "Refused");
  18. list.put(2, "User needs device registration");
  19. list.put(5, "Invalid code");
  20. list.put(50, "Failed to send mail");
  21. list.put(51, "Incorrect mail adress");
  22. list.put(52, "Mail not equal");
  23. list.put(80, "Failed to connect to LDAP server");
  24. list.put(81, "Error reading attribute");
  25. list.put(82, "Error writing attribute");
  26. list.put(83, "Failed to register device");
  27. // Data errors
  28. list.put(500, "No data given");
  29. list.put(555, "Unsupported function");
  30. list.put(560, "Missing variables");
  31. //DB errors
  32. list.put(600, "DB connection coun\'t be established");
  33. list.put(601, "Failed to write to DB");
  34. list.put(602, "Failed to read from DB");
  35. //LDAP errors
  36. list.put(699, "User not found");
  37. list.put(700, "OK");
  38. list.put(749, "Username / password incorrect");
  39. /* User generated errors */
  40. list.put(900, "GET request not Allowed");
  41. list.put(901, "POST request not Allowed");
  42. list.put(950, "Process timed out");
  43. if(list.get(id) != null) {
  44. return list.get(id);
  45. }
  46. else {
  47. return list.get(-1);
  48. }
  49. }
  50. }