Skip to content

Commit

Permalink
fix: simplify error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugoch committed Jan 27, 2025
1 parent 4c8bf7f commit 19bb3bf
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions router/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ pub async fn run(

let tokenizer: Result<Tokenizer, WebServerError> = {
use pyo3::prelude::*;
match Python::with_gil(|py| -> PyResult<()> {
let res = Python::with_gil(|py| -> PyResult<()> {
py_resolve_tokenizer(py, &tokenizer_name, revision.as_deref(), trust_remote_code)?;
Ok(())
})
Expand All @@ -1834,13 +1834,11 @@ pub async fn run(
.or_else(|err| {
let out = legacy_tokenizer_handle(config_filename.as_ref());
out.ok_or(err)
}) {
Ok(_) => {}
Err(_) => {
return Err(WebServerError::Tokenizer(
"Unable to load tokenizer.".to_string(),
));
}
}).map_err(|_|WebServerError::Tokenizer(
"Unable to load tokenizer.".to_string(),
));
if res.is_err(){
return res
}
let filename = "out/tokenizer.json";
if let Ok(tok) = tokenizers::Tokenizer::from_file(filename) {
Expand Down

0 comments on commit 19bb3bf

Please sign in to comment.