API Docs for: 3.17.2
Show:

File: test/js/AssertionError.js

  1. /**
  2. * Error is thrown whenever an assertion fails. It provides methods
  3. * to more easily get at error information and also provides a base class
  4. * from which more specific assertion errors can be derived.
  5. *
  6. * @param {String} message The message to display when the error occurs.
  7. * @namespace Test
  8. * @module test
  9. * @class AssertionError
  10. * @constructor
  11. */
  12. YUITest.AssertionError = function (message){
  13.  
  14. /**
  15. * Error message. Must be duplicated to ensure browser receives it.
  16. * @type String
  17. * @property message
  18. */
  19. this.message = message;
  20.  
  21. /**
  22. * The name of the error that occurred.
  23. * @type String
  24. * @property name
  25. */
  26. this.name = "Assert Error";
  27. };
  28.  
  29. YUITest.AssertionError.prototype = {
  30.  
  31. //restore constructor
  32. constructor: YUITest.AssertionError,
  33.  
  34. /**
  35. * Returns a fully formatted error for an assertion failure. This should
  36. * be overridden by all subclasses to provide specific information.
  37. * @method getMessage
  38. * @return {String} A string describing the error.
  39. */
  40. getMessage : function () {
  41. return this.message;
  42. },
  43.  
  44. /**
  45. * Returns a string representation of the error.
  46. * @method toString
  47. * @return {String} A string representation of the error.
  48. */
  49. toString : function () {
  50. return this.name + ": " + this.getMessage();
  51. }
  52.  
  53. };
  54.