refactor: complete error message unification (Phase 3.5)
Migrate remaining 45 error generation patterns to unified helpers: - calls.rs: 13 sites → 0 - extern_provider.rs: 9 sites → 0 - externals.rs: 5 sites → 0 - boxes_plugin.rs: 5 sites → 0 - boxes.rs: 5 sites → 0 - boxes_string.rs: 4 sites → 0 - boxes_instance.rs: 2 sites → 0 - mod.rs + boxes_array.rs: 2 sites → 0 Error patterns now 100% unified: - All 80 InvalidInstruction sites use helpers (100%) - Consistent error formatting across entire codebase - Single source of truth for error messages Code reduction: - Phase 3.5: 50-70 lines saved - Cumulative (Phase 1+2+3+3.5): 200-267 lines removed (6-8% handlers) - Total patterns unified: 192 (destination 60 + args 52 + errors 80) Benefits: - 100% error message consistency achieved - Easy to modify error formats globally - Foundation for i18n support ready - Improved maintainability and testability Test results: ✓ Build successful, Phase 21.0 smoke tests passing Related: Phase 21.0 refactoring milestone complete Risk: Low (error messages only, behavior preserved)
This commit is contained in:
@ -11,7 +11,7 @@ impl MirInterpreter {
|
||||
) -> Result<(), VMError> {
|
||||
// Provider Lock guard (受け口・既定は挙動不変)
|
||||
if let Err(e) = crate::runtime::provider_lock::guard_before_new_box(box_type) {
|
||||
return Err(VMError::InvalidInstruction(e));
|
||||
return Err(self.err_invalid(e));
|
||||
}
|
||||
let mut converted: Vec<Box<dyn NyashBox>> = Vec::with_capacity(args.len());
|
||||
for vid in args {
|
||||
@ -22,9 +22,7 @@ impl MirInterpreter {
|
||||
.lock()
|
||||
.unwrap()
|
||||
.create_box(box_type, &converted)
|
||||
.map_err(|e| {
|
||||
VMError::InvalidInstruction(format!("NewBox {} failed: {}", box_type, e))
|
||||
})?;
|
||||
.map_err(|e| self.err_with_context(&format!("NewBox {}", box_type), &e.to_string()))?;
|
||||
// Store created instance first so 'me' can be passed to birth
|
||||
let created_vm = VMValue::from_nyash_box(created);
|
||||
self.regs.insert(dst, created_vm.clone());
|
||||
@ -74,10 +72,10 @@ impl MirInterpreter {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(VMError::InvalidInstruction(format!(
|
||||
"PluginInvoke {}.{} failed: {:?}",
|
||||
p.box_type, method, e
|
||||
)))
|
||||
return Err(self.err_with_context(
|
||||
&format!("PluginInvoke {}.{}", p.box_type, method),
|
||||
&format!("{:?}", e)
|
||||
))
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -88,11 +86,7 @@ impl MirInterpreter {
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(VMError::InvalidInstruction(format!(
|
||||
"PluginInvoke unsupported on {} for method {}",
|
||||
recv_box.type_name(),
|
||||
method
|
||||
)))
|
||||
Err(self.err_method_not_found(&recv_box.type_name(), method))
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +182,7 @@ impl MirInterpreter {
|
||||
}
|
||||
if user_instance_class.is_some() && !crate::config::env::vm_allow_user_instance_boxcall() {
|
||||
let cls = user_instance_class.unwrap();
|
||||
return Err(VMError::InvalidInstruction(format!(
|
||||
return Err(self.err_invalid(format!(
|
||||
"User Instance BoxCall disallowed in prod: {}.{} (enable builder rewrite)",
|
||||
cls, method
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user