Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Jul 1, 2023
1 parent 0b5663c commit 0e91f83
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jboss.vfs.VFS;
import org.jboss.vfs.VFSUtils;
import sass.embedded_protocol.EmbeddedSass.InboundMessage.ImportResponse.ImportSuccess;
import sass.embedded_protocol.EmbeddedSass.Syntax;

import javax.annotation.Nullable;
import java.io.File;
Expand Down Expand Up @@ -113,7 +114,13 @@ public ImportSuccess handleImport(URL url) throws Exception {
try (InputStream in = urlConnection.getInputStream()) {
ByteString content = ByteString.readFrom(in);
result.setContentsBytes(content);
result.setSyntax(SyntaxUtil.guessSyntax(urlConnection));

Syntax syntax = SyntaxUtil.guessSyntax(urlConnection);
if (syntax == Syntax.UNRECOGNIZED) {
throw new IllegalStateException("Failed to guess syntax for " + url);
} else {
result.setSyntax(syntax);
}
}

return result.build();
Expand Down

0 comments on commit 0e91f83

Please sign in to comment.