MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / runtime_error

Method runtime_error

aiscript-vm/src/vm/state.rs:285–309  ·  view source on GitHub ↗
(&mut self, message: Cow<'static, str>)

Source from the content-addressed store, hash-verified

283
284impl<'gc> State<'gc> {
285 fn runtime_error(&mut self, message: Cow<'static, str>) -> VmError {
286 let mut error_message = String::from(message);
287 for i in (0..self.frame_count).rev() {
288 let frame = &self.frames[i];
289 // Break loop if reach the un-initialized callframe.
290 // Call Vm::eval_function directly will reach this case,
291 // since it never init the root script.
292 if frame.ip == 0 {
293 break;
294 }
295 let function = &frame.closure.function;
296 error_message.push_str(&format!(
297 "\n[line {}] in ",
298 function.chunk.line(frame.ip - 1)
299 ));
300 let name = if let Some(name) = function.name {
301 name.to_str().unwrap()
302 } else {
303 "script"
304 };
305 error_message.push_str(name);
306 error_message.push('\n');
307 }
308 VmError::RuntimeError(error_message)
309 }
310
311 fn current_frame(&mut self) -> &mut CallFrame<'gc> {
312 &mut self.frames[self.frame_count - 1]

Callers 9

dispatch_nextMethod · 0.80
define_methodMethod · 0.80
bind_methodMethod · 0.80
call_constructorMethod · 0.80
call_valueMethod · 0.80
invoke_from_classMethod · 0.80
invokeMethod · 0.80
prepare_argsMethod · 0.80
check_argsMethod · 0.80

Calls 3

RuntimeErrorClass · 0.85
to_strMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected