Dieses Repository beinhaltet HTML- und Javascript Code zur einer NotizenWebApp auf Basis von Web Storage. Zudem sind Mocha/Chai Tests im Browser enthalten. https://meinenotizen.netlify.app/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

check-error.js 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.checkError = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. 'use strict';
  3. /* !
  4. * Chai - checkError utility
  5. * Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
  6. * MIT Licensed
  7. */
  8. /**
  9. * ### .checkError
  10. *
  11. * Checks that an error conforms to a given set of criteria and/or retrieves information about it.
  12. *
  13. * @api public
  14. */
  15. /**
  16. * ### .compatibleInstance(thrown, errorLike)
  17. *
  18. * Checks if two instances are compatible (strict equal).
  19. * Returns false if errorLike is not an instance of Error, because instances
  20. * can only be compatible if they're both error instances.
  21. *
  22. * @name compatibleInstance
  23. * @param {Error} thrown error
  24. * @param {Error|ErrorConstructor} errorLike object to compare against
  25. * @namespace Utils
  26. * @api public
  27. */
  28. function compatibleInstance(thrown, errorLike) {
  29. return errorLike instanceof Error && thrown === errorLike;
  30. }
  31. /**
  32. * ### .compatibleConstructor(thrown, errorLike)
  33. *
  34. * Checks if two constructors are compatible.
  35. * This function can receive either an error constructor or
  36. * an error instance as the `errorLike` argument.
  37. * Constructors are compatible if they're the same or if one is
  38. * an instance of another.
  39. *
  40. * @name compatibleConstructor
  41. * @param {Error} thrown error
  42. * @param {Error|ErrorConstructor} errorLike object to compare against
  43. * @namespace Utils
  44. * @api public
  45. */
  46. function compatibleConstructor(thrown, errorLike) {
  47. if (errorLike instanceof Error) {
  48. // If `errorLike` is an instance of any error we compare their constructors
  49. return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
  50. } else if (errorLike.prototype instanceof Error || errorLike === Error) {
  51. // If `errorLike` is a constructor that inherits from Error, we compare `thrown` to `errorLike` directly
  52. return thrown.constructor === errorLike || thrown instanceof errorLike;
  53. }
  54. return false;
  55. }
  56. /**
  57. * ### .compatibleMessage(thrown, errMatcher)
  58. *
  59. * Checks if an error's message is compatible with a matcher (String or RegExp).
  60. * If the message contains the String or passes the RegExp test,
  61. * it is considered compatible.
  62. *
  63. * @name compatibleMessage
  64. * @param {Error} thrown error
  65. * @param {String|RegExp} errMatcher to look for into the message
  66. * @namespace Utils
  67. * @api public
  68. */
  69. function compatibleMessage(thrown, errMatcher) {
  70. var comparisonString = typeof thrown === 'string' ? thrown : thrown.message;
  71. if (errMatcher instanceof RegExp) {
  72. return errMatcher.test(comparisonString);
  73. } else if (typeof errMatcher === 'string') {
  74. return comparisonString.indexOf(errMatcher) !== -1; // eslint-disable-line no-magic-numbers
  75. }
  76. return false;
  77. }
  78. /**
  79. * ### .getFunctionName(constructorFn)
  80. *
  81. * Returns the name of a function.
  82. * This also includes a polyfill function if `constructorFn.name` is not defined.
  83. *
  84. * @name getFunctionName
  85. * @param {Function} constructorFn
  86. * @namespace Utils
  87. * @api private
  88. */
  89. var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/;
  90. function getFunctionName(constructorFn) {
  91. var name = '';
  92. if (typeof constructorFn.name === 'undefined') {
  93. // Here we run a polyfill if constructorFn.name is not defined
  94. var match = String(constructorFn).match(functionNameMatch);
  95. if (match) {
  96. name = match[1];
  97. }
  98. } else {
  99. name = constructorFn.name;
  100. }
  101. return name;
  102. }
  103. /**
  104. * ### .getConstructorName(errorLike)
  105. *
  106. * Gets the constructor name for an Error instance or constructor itself.
  107. *
  108. * @name getConstructorName
  109. * @param {Error|ErrorConstructor} errorLike
  110. * @namespace Utils
  111. * @api public
  112. */
  113. function getConstructorName(errorLike) {
  114. var constructorName = errorLike;
  115. if (errorLike instanceof Error) {
  116. constructorName = getFunctionName(errorLike.constructor);
  117. } else if (typeof errorLike === 'function') {
  118. // If `err` is not an instance of Error it is an error constructor itself or another function.
  119. // If we've got a common function we get its name, otherwise we may need to create a new instance
  120. // of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more.
  121. constructorName = getFunctionName(errorLike).trim() ||
  122. getFunctionName(new errorLike()); // eslint-disable-line new-cap
  123. }
  124. return constructorName;
  125. }
  126. /**
  127. * ### .getMessage(errorLike)
  128. *
  129. * Gets the error message from an error.
  130. * If `err` is a String itself, we return it.
  131. * If the error has no message, we return an empty string.
  132. *
  133. * @name getMessage
  134. * @param {Error|String} errorLike
  135. * @namespace Utils
  136. * @api public
  137. */
  138. function getMessage(errorLike) {
  139. var msg = '';
  140. if (errorLike && errorLike.message) {
  141. msg = errorLike.message;
  142. } else if (typeof errorLike === 'string') {
  143. msg = errorLike;
  144. }
  145. return msg;
  146. }
  147. module.exports = {
  148. compatibleInstance: compatibleInstance,
  149. compatibleConstructor: compatibleConstructor,
  150. compatibleMessage: compatibleMessage,
  151. getMessage: getMessage,
  152. getConstructorName: getConstructorName,
  153. };
  154. },{}]},{},[1])(1)
  155. });