Skip to content

Commit 5dec654

Browse files
authored
Merge pull request #162 from advanced-security/lcartey/capture-and-report-compilation-errors
Capture and report CDS compilation errors
2 parents 0ea21ec + 9f1a4a5 commit 5dec654

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

extractors/cds/tools/index-files.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ echo "Processing CDS files to JSON"
5252
# the same name
5353
while IFS= read -r cds_file; do
5454
echo "Processing CDS file $cds_file to:"
55-
$cds_command compile "$cds_file" \
56-
-2 json \
57-
-o "$cds_file.json" \
58-
--locations
55+
if ! $cds_command compile "$cds_file" -2 json -o "$cds_file.json" --locations 2> "$cds_file.err"; then
56+
stderr_truncated=`grep "^\[ERROR\]" "$cds_file.err" | tail -n 4`
57+
error_message=$'Could not compile the file '"$cds_file"$'.\nReported error(s):\n```\n'"$stderr_truncated"$'\n```'
58+
echo "$error_message"
59+
# Log an error diagnostic which appears on the status page
60+
"$CODEQL_DIST/codeql" database add-diagnostic --extractor-name cds --ready-for-status-page --source-id cds/compilation-failure --source-name "Failure to compile one or more SAP CAP CDS files" --severity error --markdown-message "$error_message" --file-path "$cds_file" "$CODEQL_EXTRACTOR_CDS_WIP_DATABASE"
61+
fi
5962
done < "$response_file"
6063

6164
# Check if the JS extractor variables are set, and set them if not

0 commit comments

Comments
 (0)