diff options
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 { |