Skip to content

Commit fd16b99

Browse files
committed
Throw - dont panic for when Typst tries to access non virtual files
1 parent 612453d commit fd16b99

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/render-pdf/src/typst_context/context.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use getset::Getters;
88
use log::trace;
99
use typst::{
1010
Library, World,
11+
diag::FileError,
12+
ecow::EcoString,
1113
foundations::{Bytes, Datetime},
1214
syntax::{FileId, Source},
1315
text::{Font, FontBook},
@@ -73,8 +75,11 @@ impl World for TypstContext {
7375
}
7476
}
7577

76-
fn file(&self, _id: FileId) -> typst::diag::FileResult<Bytes> {
77-
panic!("File access not implemented in this minimal example")
78+
fn file(&self, id: FileId) -> typst::diag::FileResult<Bytes> {
79+
Err(FileError::Other(Some(EcoString::inline(&format!(
80+
"Tried to access non-virtual file with ID: {:?}",
81+
id
82+
)))))
7883
}
7984

8085
fn font(&self, index: usize) -> Option<Font> {

0 commit comments

Comments
 (0)