Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some more configuration errors #2786

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

henrymercer
Copy link
Contributor

Had an old branch on my machine that adds a couple of configuration errors.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

@Copilot Copilot bot review requested due to automatic review settings February 26, 2025 16:54
@henrymercer henrymercer requested a review from a team as a code owner February 26, 2025 16:54

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refines error handling around downloading and extracting the CodeQL CLI and introduces a new error category for temporary directory issues.

  • Updates error rethrowing in both JavaScript and TypeScript implementations to conditionally use a ConfigurationError.
  • Adds a new error category "CouldNotCreateTempDir" in both the JS and TS CLI error modules.

Reviewed Changes

File Description
lib/codeql.js Refactors error handling in the CLI setup to use a dynamic error type based on conditions.
src/codeql.ts Mirrors the same error handling improvements as in lib/codeql.js.
lib/cli-errors.js Introduces a new error category "CouldNotCreateTempDir" to better classify temp directory errors.
src/cli-errors.ts Adds the "CouldNotCreateTempDir" enum member, aligning with the changes in the JS error module.

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

lib/codeql.js:136

  • Consider using a helper function or preserving the original error (including its prototype and stack trace) when rethrowing. This can improve debuggability by retaining more context from the original error.
const ErrorClass = e instanceof util.ConfigurationError || (e instanceof Error && e.message.includes("ENOSPC")) // out of disk space

src/codeql.ts:380

  • Similar to the JS version, consider preserving the original error context by wrapping or logging the actual error object when rethrowing it. Maintaining the original error's details can help with future debugging.
const ErrorClass = e instanceof util.ConfigurationError || (e instanceof Error && e.message.includes("ENOSPC")) // out of disk space

lib/cli-errors.js:113

  • The new error category 'CouldNotCreateTempDir' appears clear; please ensure downstream error handling also recognizes and properly handles this category.
CliConfigErrorCategory["CouldNotCreateTempDir"] = "CouldNotCreateTempDir";

src/cli-errors.ts:122

  • Ensure that the error messages or handling logic associated with 'CouldNotCreateTempDir' are consistent with its usage in the JS version.
CouldNotCreateTempDir = "CouldNotCreateTempDir",

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants