summaryrefslogtreecommitdiff
path: root/runtime/worker.rs
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2021-04-21 21:22:00 +0530
committerGitHub <noreply@github.com>2021-04-21 17:52:00 +0200
commit3b78f6c4493093701660bba496d87342ffbc08d7 (patch)
tree8c7a52188f8ead12cab1078f5e5cb4ae62387ba2 /runtime/worker.rs
parent320c19c7c09f18af7647f2a278dd8c3e18bffba4 (diff)
fix: do not panic on not found cwd (#10238)
Diffstat (limited to 'runtime/worker.rs')
-rw-r--r--runtime/worker.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 253725533..6de87f52e 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -8,6 +8,7 @@ use crate::metrics::RuntimeMetrics;
use crate::ops;
use crate::permissions::Permissions;
use deno_core::error::AnyError;
+use deno_core::error::Context as ErrorContext;
use deno_core::futures::future::poll_fn;
use deno_core::futures::future::FutureExt;
use deno_core::futures::stream::StreamExt;
@@ -201,7 +202,9 @@ impl MainWorker {
/// Same as execute2() but the filename defaults to "$CWD/__anonymous__".
pub fn execute(&mut self, js_source: &str) -> Result<(), AnyError> {
- let path = env::current_dir().unwrap().join("__anonymous__");
+ let path = env::current_dir()
+ .context("Failed to get current working directory")?
+ .join("__anonymous__");
let url = Url::from_file_path(path).unwrap();
self.js_runtime.execute(url.as_str(), js_source)
}