diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-04-25 09:31:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 09:31:54 -0400 |
commit | 0c47cd67850e4c195212c8edfcb3a62b8435ed3a (patch) | |
tree | b397da0f498e76e078b6b79365388b31f2bd97ba /cli/state.rs | |
parent | b28e60ecaf5d48c36cb435361834f4884d9451c2 (diff) |
introduce unstable flag, make a few things unstable (#4892)
Diffstat (limited to 'cli/state.rs')
-rw-r--r-- | cli/state.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/state.rs b/cli/state.rs index 96be28f2f..40662b563 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -230,6 +230,23 @@ impl State { dispatcher(isolate, &state, args, zero_copy) } } + + /// Quits the process if the --unstable flag was not provided. + /// + /// This is intentionally a non-recoverable check so that people cannot probe + /// for unstable APIs from stable programs. + pub fn check_unstable(&self, api_name: &str) { + // TODO(ry) Maybe use IsolateHandle::terminate_execution here to provide a + // stack trace in JS. + let s = self.0.borrow(); + if !s.global_state.flags.unstable { + eprintln!( + "Unstable API '{}'. The --unstable flag must be provided.", + api_name + ); + std::process::exit(70); + } + } } impl ModuleLoader for State { |