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.

errors.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use strict';
  2. /* istanbul ignore file: https://github.com/nodejs/node/blob/master/lib/internal/errors.js */
  3. const makeError = (Base, key, getMessage) => {
  4. module.exports[key] = class NodeError extends Base {
  5. constructor(...args) {
  6. super(typeof getMessage === 'string' ? getMessage : getMessage(args));
  7. this.name = `${super.name} [${key}]`;
  8. this.code = key;
  9. }
  10. };
  11. };
  12. makeError(TypeError, 'ERR_INVALID_ARG_TYPE', args => {
  13. const type = args[0].includes('.') ? 'property' : 'argument';
  14. let valid = args[1];
  15. const isManyTypes = Array.isArray(valid);
  16. if (isManyTypes) {
  17. valid = `${valid.slice(0, -1).join(', ')} or ${valid.slice(-1)}`;
  18. }
  19. return `The "${args[0]}" ${type} must be ${isManyTypes ? 'one of' : 'of'} type ${valid}. Received ${typeof args[2]}`;
  20. });
  21. makeError(TypeError, 'ERR_INVALID_PROTOCOL', args => {
  22. return `Protocol "${args[0]}" not supported. Expected "${args[1]}"`;
  23. });
  24. makeError(Error, 'ERR_HTTP_HEADERS_SENT', args => {
  25. return `Cannot ${args[0]} headers after they are sent to the client`;
  26. });
  27. makeError(TypeError, 'ERR_INVALID_HTTP_TOKEN', args => {
  28. return `${args[0]} must be a valid HTTP token [${args[1]}]`;
  29. });
  30. makeError(TypeError, 'ERR_HTTP_INVALID_HEADER_VALUE', args => {
  31. return `Invalid value "${args[0]} for header "${args[1]}"`;
  32. });
  33. makeError(TypeError, 'ERR_INVALID_CHAR', args => {
  34. return `Invalid character in ${args[0]} [${args[1]}]`;
  35. });