MediumPro challengeJavaScriptTypeScript

Error Boundary

ReactErrorsPatterns

Implement solve(renderFns) where each renderFn may throw.
Wrap each in an error boundary that:

  • If render succeeds: include result in output.
  • If render throws: include 'ERROR: <message>'.

renderFns is an array of source code strings (eval'd to functions).

Sample tests

Test #1Success
Input: [["() => \"ok\""]]
Output: ["ok"]
Test #2Throw
Input: [["() => { throw new Error(\"boom\"); }"]]
Output: ["ERROR: boom"]
Test #3Mixed
Input: [["() => \"a\"","() => { throw new Error(\"b\"); }","() => \"c\""]]
Output: ["a","ERROR: b","c"]
Test #4No fns
Input: [[]]
Output: []
Test #5Two errors isolated
Input: [["() => { throw new Error(\"x\"); }","() => { throw new Error(\"y\"); }"]]
Output: ["ERROR: x","ERROR: y"]