Skip to content

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