Skip to content

Wrap URI.parse() call in try ... catch#180

Merged
aeschli merged 1 commit intomicrosoft:masterfrom
sryze:uri-parse-error
Oct 7, 2019
Merged

Wrap URI.parse() call in try ... catch#180
aeschli merged 1 commit intomicrosoft:masterfrom
sryze:uri-parse-error

Conversation

@sryze
Copy link
Contributor

@sryze sryze commented Oct 5, 2019

When URI.parse() encounters an invalid URL it can throw a URIError, but the error is never caught and it pops up in the user's face (issue #173). So this patch simply puts the parse call in a try ... catch statement.

I don't know if the URI library is supposed to throw an error in this case, it may be an issue with vscode-uri.

Steps to reproduce the error:

  1. Create a file named test.scss
  2. Paste:
.test {
    background: url('<%=invalid%>');
}
  1. Open the file in VS Code and observe an error notification:

error-popup

If you are wondering why I would be using an invalid URL - it's not really invalid, the CSS file produced by the SCSS compiler in my project is included inline into a JSP page, and the url() actually contains a JSP echo tag inside (<%=some expression%>). This used to work in VS Code 1.36 and earlier, but started to throw an error in newer releases.

@aeschli aeschli merged commit 5106f17 into microsoft:master Oct 7, 2019
@aeschli
Copy link
Collaborator

aeschli commented Oct 7, 2019

Looks good, thanks @sryze !

@aeschli aeschli added this to the October 2019 milestone Oct 7, 2019
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