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

Function fesCore

src/core/friendly_errors/fes_core.js:28–1149  ·  view source on GitHub ↗
(p5, fn, lifecycles)

Source from the content-addressed store, hash-verified

26import * as contants from '../constants';
27
28function fesCore(p5, fn, lifecycles){
29 // p5.js blue, p5.js orange, auto dark green; fallback p5.js darkened magenta
30 // See testColors below for all the color codes and names
31 const typeColors = ['#2D7BB6', '#EE9900', '#4DB200', '#C83C00'];
32 let misusedAtTopLevelCode = null;
33 let defineMisusedAtTopLevelCode = null;
34
35 // the threshold for the maximum allowed levenshtein distance
36 // used in misspelling detection
37 const EDIT_DIST_THRESHOLD = 2;
38
39 // to enable or disable styling (color, font-size, etc. ) for fes messages
40 const ENABLE_FES_STYLING = false;
41
42 // Used for internally thrown errors that should not get wrapped by another
43 // friendly error handler
44 class FESError extends Error {};
45
46 if (typeof IS_MINIFIED !== 'undefined') {
47 p5._friendlyError =
48 p5._checkForUserDefinedFunctions =
49 p5._fesErrorMonitor =
50 () => {};
51 } else {
52 let doFriendlyWelcome = false; // TEMP until we get it all working LM
53
54 // const errorTable = require('./browser_errors').default;
55
56 // -- Borrowed from jQuery 1.11.3 --
57 const class2type = {};
58 const toString = class2type.toString;
59 const names = [
60 'Boolean',
61 'Number',
62 'String',
63 'Function',
64 'Array',
65 'Date',
66 'RegExp',
67 'Object',
68 'Error'
69 ];
70 for (let n = 0; n < names.length; n++) {
71 class2type[`[object ${names[n]}]`] = names[n].toLowerCase();
72 }
73 const getType = obj => {
74 if (obj == null) {
75 return `${obj}`;
76 }
77 return typeof obj === 'object' || typeof obj === 'function'
78 ? class2type[toString.call(obj)] || 'object'
79 : typeof obj;
80 };
81
82 // -- End borrow --
83
84 // entry points into user-defined code
85 const entryPoints = [

Callers

nothing calls this directly

Calls 5

translatorFunction · 0.90
friendlyWelcomeFunction · 0.85
getTypeFunction · 0.85
mapToReferenceFunction · 0.85
getSymbolsFunction · 0.85

Tested by

no test coverage detected