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

fix: sendError() doesn't throw an error anymore when no format is specified #274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joss-enet
Copy link

As an example, the following code would send an error:

class CustomDebugSession extends DebugSession {
  protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void {
    this.sendErrorResponse(response, 100);
  }
}

The error in question: Uncaught Error Error: TypeError: Cannot read properties of undefined (reading 'replace')

This is due to the method sendErrorResponse() calling formatPII() even though no format is passed to the former.
The solution adopted was to assign an empty string as the format if none was passed as an argument. Another solution could be to make the format argument mandatory.

@connor4312
Copy link
Member

DAP specifies the format is required. So I think the method signature should change to be an overload:

protected sendErrorResponse(response: DebugProtocol.Response, message: DebugProtocol.Message)
protected sendErrorResponse(response: DebugProtocol.Response, code: number, format: string, variables?: Record<string, any>, dest: ErrorDestination = ErrorDestination.User)
protected sendErrorResponse(response: DebugProtocol.Response, codeOrMessage: number | DebugProtocol.Message, format?: string, variables?: any, dest: ErrorDestination = ErrorDestination.User) {
...
}

thoughts @roblourens?

@roblourens
Copy link
Member

Agree

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.

3 participants