ErrorCode.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import java.util.HashMap;
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. /**
  8. *
  9. * @author Deben
  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(50, "Failed to send mail");
  19. list.put(51, "Incorrect mail adress");
  20. list.put(52, "Mail not equal");
  21. list.put(80, "Failed to connect to LDAP server");
  22. list.put(81, "Error reading attribute");
  23. list.put(82, "Error writing attribute");
  24. // Data errors
  25. list.put(500, "No data given");
  26. list.put(555, "Unsupported function");
  27. list.put(560, "Missing variables");
  28. //DB errors
  29. list.put(600, "DB connection coun\'t be established");
  30. list.put(601, "Failed to write to DB");
  31. list.put(602, "Failed to read from DB");
  32. //LDAP errors
  33. list.put(700, "OK");
  34. list.put(749, "Username / password incorrect");
  35. /* User generated errors */
  36. list.put(900, "GET request not Allowed");
  37. list.put(901, "POST request not Allowed");
  38. list.put(950, "Process timed out");
  39. if(list.get(id) != null) {
  40. return list.get(id);
  41. }
  42. else {
  43. return list.get(-1);
  44. }
  45. }
  46. }