PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/core/error.d

http://github.com/LindseyB/djehuty
D | 61 lines | 37 code | 11 blank | 13 comment | 0 complexity | 395c155892ea172c280c2c513cd697ab MD5 | raw file
  1. /*
  2. * error.d
  3. *
  4. * This module implements the Error objects useable by the system.
  5. * This objects are for irrecoverable failures.
  6. *
  7. * Originated: May 8th, 2010
  8. *
  9. */
  10. module core.error;
  11. import core.exception;
  12. // Description: This is for non irrecoverable failure.
  13. class Error : Exception {
  14. this(string msg, string file = "", ulong line = 0) {
  15. super(msg, file, line);
  16. }
  17. private:
  18. // Error _next;
  19. }
  20. abstract class RuntimeError : Error {
  21. this(string msg, string file, ulong line){
  22. super(msg,file,line);
  23. }
  24. static:
  25. // Description: This Error is thrown when assertions fail.
  26. class Assert : RuntimeError {
  27. this(string msg, string file, ulong line) {
  28. super("Assertion `" ~ msg ~ "` failed", file, line);
  29. }
  30. this(string file, ulong line) {
  31. super("Assertion failed",file,line);
  32. }
  33. }
  34. class CyclicDependency : RuntimeError {
  35. this(string moduleNameA, string moduleNameB) {
  36. super("Cyclic Dependency detected between " ~ moduleNameA ~ " and " ~ moduleNameB, "", 0);
  37. }
  38. }
  39. // Description: This Error is thrown when a switch statement does not have a default and there is no case available.
  40. class NoDefaultCase : RuntimeError {
  41. this(string file, ulong line) {
  42. super("Switch has no default",file,line);
  43. }
  44. }
  45. class NoCompare : RuntimeError {
  46. this(string className) {
  47. super("Class " ~ className ~ " needs an opCmp.", "", 0);
  48. }
  49. }
  50. }