proper error handling on deps.v

main
Joca 2025-11-24 20:10:51 -03:00
parent 9d3d5fb105
commit f74b93ddf6
Signed by: jocadbz
GPG Key ID: B1836DCE2F50BDF7
1 changed files with 10 additions and 3 deletions

13
deps/deps.v vendored
View File

@ -5,7 +5,9 @@ import config
pub fn extract_dependencies(source_file string) ![]string {
mut dependencies := []string{}
content := os.read_file(source_file) or { return []string{} }
content := os.read_file(source_file) or {
return error('Failed to read source file ${source_file}: ${err}')
}
mut in_string := false
mut current_string_char := rune(0)
@ -63,14 +65,19 @@ pub fn extract_dependencies(source_file string) ![]string {
}
pub fn generate_dependency_file(source_file string, object_file string, dep_file string) {
dependencies := extract_dependencies(source_file) or { return }
dependencies := extract_dependencies(source_file) or {
eprintln('Warning: Failed to extract dependencies from ${source_file}: ${err}')
return
}
mut content := '${object_file}: ${source_file}\n'
for dep in dependencies {
content += '\t${dep}\n'
}
os.write_file(dep_file, content) or { }
os.write_file(dep_file, content) or {
eprintln('Warning: Failed to write dependency file ${dep_file}: ${err}')
}
}
// Fetch and extract dependencies declared in the build config