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:
@ -155,7 +155,7 @@ impl MirInterpreter {
|
||||
// Note: This branch is used for ExternCall form; provider toggles must be ON.
|
||||
if std::env::var("NYASH_LLVM_USE_CAPI").ok().as_deref() != Some("1") ||
|
||||
std::env::var("HAKO_V1_EXTERN_PROVIDER_C_ABI").ok().as_deref() != Some("1") {
|
||||
return Err(VMError::InvalidInstruction("env.codegen.link_object: C-API route disabled".into()));
|
||||
return Err(self.err_invalid("env.codegen.link_object: C-API route disabled"));
|
||||
}
|
||||
// Extract array payload
|
||||
let (obj_path, exe_out) = if let Some(a2) = args.get(2) {
|
||||
@ -177,13 +177,13 @@ impl MirInterpreter {
|
||||
_ => (v.to_string(), None),
|
||||
}
|
||||
} else {
|
||||
return Err(VMError::InvalidInstruction("extern_invoke env.codegen.link_object expects args array".into()));
|
||||
return Err(self.err_invalid("extern_invoke env.codegen.link_object expects args array"));
|
||||
};
|
||||
let extra = std::env::var("HAKO_AOT_LDFLAGS").ok();
|
||||
let obj = std::path::PathBuf::from(obj_path);
|
||||
let exe = exe_out.map(std::path::PathBuf::from).unwrap_or_else(|| std::env::temp_dir().join("hako_link_out.exe"));
|
||||
crate::host_providers::llvm_codegen::link_object_capi(&obj, &exe, extra.as_deref())
|
||||
.map_err(|e| VMError::InvalidInstruction(format!("env.codegen.link_object: {}", e)))?;
|
||||
.map_err(|e| self.err_with_context("env.codegen.link_object", &e.to_string()))?;
|
||||
self.write_result(dst, VMValue::String(exe.to_string_lossy().into_owned()));
|
||||
Ok(())
|
||||
}
|
||||
@ -195,9 +195,9 @@ impl MirInterpreter {
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
return Err(VMError::InvalidInstruction("hostbridge.extern_invoke unsupported [externals]".into()));
|
||||
return Err(self.err_invalid("hostbridge.extern_invoke unsupported [externals]"));
|
||||
}
|
||||
_ => Err(VMError::InvalidInstruction(format!(
|
||||
_ => Err(self.err_invalid(format!(
|
||||
"ExternCall {}.{} not supported",
|
||||
iface, method
|
||||
))),
|
||||
|
||||
Reference in New Issue
Block a user