meilleur gestion des erreur dans sheebr et dans chibrax/kernel.js

This commit is contained in:
Marc
2021-12-14 14:45:15 +01:00
parent 4aee41a5d6
commit 5e116fb3ac
2 changed files with 24 additions and 14 deletions
+4 -6
View File
@@ -25,13 +25,12 @@ function finit_module(path, params = "", flags = 0) {
const fileDescriptor = open(path, modes.O_RDONLY)
const result = syscall(SYSCALL_FINIT_MODULE, fileDescriptor, params, flags)
if(result > 0) {
//parse linux error
console.log(errno[result])
throw new Error(errno[result])
} else {
if(result == -1) {
console.log('non number or string argument recived')
throw new Error('non number or string argument recived')
}else if(result == -2) {
console.log('unsuported argument length (1-5)')
throw new Error('unsuported argument length (1-5)')
}
}
}
@@ -52,8 +51,7 @@ function modprobe(modulename) {
if(fs.existsSync(path.join('/lib/modules', name, 'kernel', modulename))) {
finit_module(path.join('/lib/modules', name, 'kernel', modulename))
} else {
console.log("file not found " + path.join('/lib/modules', name, 'kernel', modulename))
//throw "file not found"
throw new Error("file not found " + path.join('/lib/modules', name, 'kernel', modulename))
}
}