1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

Replace panic with invalid_utf8 OpError (#4704)

Co-authored-by: Wout Elstgeest <w.elstgeest@inepro.com>
This commit is contained in:
gewoonwoutje 2020-04-11 04:14:16 +02:00 committed by GitHub
parent 3e51e67f8a
commit 2feb661b85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -156,7 +156,8 @@ fn op_fetch_source_files(
.map_err(|e| OpError::other(e.to_string()))? .map_err(|e| OpError::other(e.to_string()))?
.code .code
} }
_ => String::from_utf8(file.source_code).unwrap(), _ => String::from_utf8(file.source_code)
.map_err(|_| OpError::invalid_utf8())?,
}; };
Ok::<_, OpError>(json!({ Ok::<_, OpError>(json!({
"url": file.url.to_string(), "url": file.url.to_string(),