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 a way to emit errors with a path #1640

Merged
merged 3 commits into from
Jan 4, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/front/wgsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,12 @@ impl ParseError {

/// Emits a summary of the error to standard error stream.
pub fn emit_to_stderr(&self, source: &str) {
let files = SimpleFile::new("wgsl", source);
self.emit_to_stderr_with_path(source, &std::path::Path::new("wgsl"))
}

/// Emits a summary of the error to standard error stream.
pub fn emit_to_stderr_with_path(&self, source: &str, path: &std::path::Path) {
let files = SimpleFile::new(path, source);
let config = codespan_reporting::term::Config::default();
let writer = StandardStream::stderr(ColorChoice::Always);
term::emit(&mut writer.lock(), &config, &files, &self.diagnostic())
Expand Down