MCPcopy Create free account
hub / github.com/dabbott/javascript-playgrounds / getErrorDetails

Function getErrorDetails

utils/ErrorMessage.js:27–48  ·  view source on GitHub ↗
(originalMessage)

Source from the content-addressed store, hash-verified

25const defaultDescription = `The web player encountered an error. When you fix the error, the web player will automatically re-run your code.`
26
27export const getErrorDetails = (originalMessage) => {
28 const firstLine = originalMessage.split('\n')[0]
29 const errorLineNumber = firstLine.match(/\((\d+)/)
30
31 const details = {
32 lineNumber: errorLineNumber && parseInt(errorLineNumber[1]) - 1,
33 summary: firstLine,
34 description: defaultDescription,
35 }
36
37 for (let i = 0; i < messages.length; i++) {
38 const [predicate, enhancer] = messages[i]
39 if (originalMessage.match(predicate)) {
40 return {
41 ...details,
42 ...enhancer(originalMessage),
43 }
44 }
45 }
46
47 return details
48}

Callers 1

Workspace.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected