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

Function mapToReference

src/core/friendly_errors/fes_core.js:138–156  ·  view source on GitHub ↗
(message, func)

Source from the content-addressed store, hash-verified

136 * @returns {String}
137 */
138 const mapToReference = (message, func) => {
139 let msgWithReference = '';
140 if (func == null || func.substring(0, 4) === 'load') {
141 msgWithReference = message;
142 } else {
143 const methodParts = func.split('.');
144 const referenceSection =
145 methodParts.length > 1 ? `${methodParts[0]}.${methodParts[1]}` : 'p5';
146
147 const funcName =
148 methodParts.length === 1 ? func : methodParts.slice(2).join('/');
149
150 //Whenever func having p5.[Class] is encountered, we need to have the error link as mentioned below else different link
151 funcName.startsWith('p5.') ?
152 msgWithReference = `${message} (https://p5js.org/reference/${referenceSection}.${funcName})` :
153 msgWithReference = `${message} (https://p5js.org/reference/${referenceSection}/${funcName})`;
154 }
155 return msgWithReference;
156 };
157
158 /**
159 * Prints out a fancy, colorful message to the console log

Callers 2

fesCoreFunction · 0.85
handleMisspellingFunction · 0.85

Calls 2

splitMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected