MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / getError

Function getError

api/src/utils/error-formatting.ts:14–24  ·  view source on GitHub ↗
(errors: ErrorObject[])

Source from the content-addressed store, hash-verified

12};
13
14const getError = (errors: ErrorObject[]): ErrorObject => {
15 // This is a guard against accidentally enabling allErrors in ajv and making
16 // the server more vulnerable to DOS.
17 const error = errors[0];
18 if (!error || errors.length !== 1) {
19 throw new Error(
20 'Bad Argument: the array of errors must have exactly one element.'
21 );
22 }
23 return error;
24};
25
26/**
27 * Format validation errors for /project-completed.

Calls

no outgoing calls

Tested by

no test coverage detected