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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.errorMessage = void 0;
  6. function _chalk() {
  7. const data = _interopRequireDefault(require('chalk'));
  8. _chalk = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _jestGetType() {
  14. const data = require('jest-get-type');
  15. _jestGetType = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. var _condition = require('./condition');
  21. var _utils = require('./utils');
  22. function _interopRequireDefault(obj) {
  23. return obj && obj.__esModule ? obj : {default: obj};
  24. }
  25. /**
  26. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  27. *
  28. * This source code is licensed under the MIT license found in the
  29. * LICENSE file in the root directory of this source tree.
  30. */
  31. const errorMessage = (option, received, defaultValue, options, path) => {
  32. const conditions = (0, _condition.getValues)(defaultValue);
  33. const validTypes = Array.from(
  34. new Set(conditions.map(_jestGetType().getType))
  35. );
  36. const message = ` Option ${_chalk().default.bold(
  37. `"${path && path.length > 0 ? path.join('.') + '.' : ''}${option}"`
  38. )} must be of type:
  39. ${validTypes.map(e => _chalk().default.bold.green(e)).join(' or ')}
  40. but instead received:
  41. ${_chalk().default.bold.red((0, _jestGetType().getType)(received))}
  42. Example:
  43. ${formatExamples(option, conditions)}`;
  44. const comment = options.comment;
  45. const name = (options.title && options.title.error) || _utils.ERROR;
  46. throw new _utils.ValidationError(name, message, comment);
  47. };
  48. exports.errorMessage = errorMessage;
  49. function formatExamples(option, examples) {
  50. return examples.map(
  51. e => ` {
  52. ${_chalk().default.bold(`"${option}"`)}: ${_chalk().default.bold(
  53. (0, _utils.formatPrettyObject)(e)
  54. )}
  55. }`
  56. ).join(`
  57. or
  58. `);
  59. }