MCPcopy Index your code
hub / github.com/processing/p5.js / collectIssue

Function collectIssue

src/core/friendly_errors/param_validator.js:418–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416 let actualType;
417
418 const collectIssue = issue => {
419 if (!issue) return;
420 if (!actualType) {
421 actualType = issue.message;
422 }
423
424 if (issue.code === 'invalid_type') {
425 actualType = issue.message.split(', received ')[1];
426 expectedTypes.add(issue.expected);
427 }
428 // The case for constants. Since we don't want to print out the actual
429 // constant values in the error message, the error message will
430 // direct users to the documentation.
431 else if (issue.code === 'invalid_value') {
432 if (Array.isArray(issue.values) && issue.values.every(v => v === Infinity || v === -Infinity)) {
433 expectedTypes.add('number');
434 } else {
435 expectedTypes.add('constant (please refer to documentation for allowed values)');
436 actualType = args[error.path[0]];
437 }
438 } else if (issue.code === 'custom') {
439 const match = issue.message.match(/Input not instance of (\w+)/);
440 if (match) expectedTypes.add(match[1]);
441 actualType = undefined;
442 } else if (issue.code === 'invalid_union') {
443 issue.errors.forEach(nestedErr => {
444 nestedErr.forEach(nestedIssue => collectIssue(nestedIssue));
445 });
446 }
447 };
448
449 error.errors.forEach(err => {
450 err.forEach(issue => collectIssue(issue));

Callers 1

processUnionErrorFunction · 0.85

Calls 2

splitMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected