diff --git a/bin/generate-test.mjs b/bin/generate-test.mjs index a90bbec..18b0639 100755 --- a/bin/generate-test.mjs +++ b/bin/generate-test.mjs @@ -34,11 +34,23 @@ } } +/** + * Converts the entire file by iterating through the RestParser object and + * converting each request into an Hurl string using the restCliRequest2Hurl + * function. + * + * @param {RestParser} parser - The RestParser object that contains the requests to be converted. + * @return {Promise} A promise that resolves to the Hurl string representation of all the requests. + */ const convertWholeFile = async (parser) => { const nb = parser.count; let hurlString = ""; for (let i = 0; i < nb; i++) { const request = await parser.get(i); + if (!request) { // Should not happen + console.error(`Request "${i}" not found.\nMaybe the examples.http file is wrong?`); + continue; + } hurlString += await restCliRequest2Hurl(request) + '\n\n'; }