Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

readme.md 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. makeerror [![Build Status](https://secure.travis-ci.org/nshah/nodejs-makeerror.png)](http://travis-ci.org/nshah/nodejs-makeerror)
  2. =========
  3. A library to make errors.
  4. Basics
  5. ------
  6. Makes an Error constructor function with the signature below. All arguments are
  7. optional, and if the first argument is not a `String`, it will be assumed to be
  8. `data`:
  9. ```javascript
  10. function(message, data)
  11. ```
  12. You'll typically do something like:
  13. ```javascript
  14. var makeError = require('makeerror')
  15. var UnknownFileTypeError = makeError(
  16. 'UnknownFileTypeError',
  17. 'The specified type is not known.'
  18. )
  19. var er = UnknownFileTypeError()
  20. ```
  21. `er` will have a prototype chain that ensures:
  22. ```javascript
  23. er instanceof UnknownFileTypeError
  24. er instanceof Error
  25. ```
  26. Templatized Error Messages
  27. --------------------------
  28. There is support for simple string substitutions like:
  29. ```javascript
  30. var makeError = require('makeerror')
  31. var UnknownFileTypeError = makeError(
  32. 'UnknownFileTypeError',
  33. 'The specified type "{type}" is not known.'
  34. )
  35. var er = UnknownFileTypeError({ type: 'bmp' })
  36. ```
  37. Now `er.message` or `er.toString()` will return `'The specified type "bmp" is
  38. not known.'`.
  39. Prototype Hierarchies
  40. ---------------------
  41. You can create simple hierarchies as well using the `prototype` chain:
  42. ```javascript
  43. var makeError = require('makeerror')
  44. var ParentError = makeError('ParentError')
  45. var ChildError = makeError(
  46. 'ChildError',
  47. 'The child error.',
  48. { proto: ParentError() }
  49. )
  50. var er = ChildError()
  51. ```
  52. `er` will have a prototype chain that ensures:
  53. ```javascript
  54. er instanceof ChildError
  55. er instanceof ParentError
  56. er instanceof Error
  57. ```