DataDog / datadog-ci

Use Datadog from your CI.
https://datadoghq.com
Apache License 2.0
129 stars 55 forks source link

[SYNTH-16108] Show error stack trace and cause #1438

Open Drarig29 opened 2 months ago

Drarig29 commented 2 months ago

What and why?

Before:

$ yarn launch synthetics run-tests -s 'test:('

 ERROR: unable to obtain test configurations with search query 
Request failed with status code 400

After:

$ yarn launch synthetics run-tests -s 'test:('

 ERROR: unable to obtain test configurations 
CriticalError: Failed to search tests with query: query on https://api.datadoghq.com/api/v1/synthetics/tests/search returned: "Make sure there is no missing parentheses"
    at /Users/corentin.girard/go/src/github.com/DataDog/datadog-ci.git/master/src/commands/synthetics/run-tests-lib.ts:85:11
    at Generator.throw (<anonymous>)
    at rejected (/Users/corentin.girard/go/src/github.com/DataDog/datadog-ci.git/master/src/commands/synthetics/run-tests-lib.ts:6:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'UNAVAILABLE_TEST_CONFIG',
  [cause]: EndpointError: Failed to search tests with query: query on https://api.datadoghq.com/api/v1/synthetics/tests/search returned: "Make sure there is no missing parentheses"
      at /Users/corentin.girard/go/src/github.com/DataDog/datadog-ci.git/master/src/commands/synthetics/test.ts:81:11
      at Generator.throw (<anonymous>)
      at rejected (/Users/corentin.girard/go/src/github.com/DataDog/datadog-ci.git/master/src/commands/synthetics/test.ts:6:65)
      at processTicksAndRejections (node:internal/process/task_queues:95:5) {
    status: 400
  }
}

How?

For each error that we catch and want to re-throw, we now attach it as a cause on the new error.

Review checklist

datadog-datadog-prod-us1[bot] commented 2 months ago

Datadog Report

Branch report: corentin.girard/SYNTH-16108/show-error-stack-trace-with-cause Commit report: 75d69b8 Test service: datadog-ci-tests

:white_check_mark: 0 Failed, 416 Passed, 0 Skipped, 52.78s Total duration (2m 34.9s time saved)