Over my nodejs application I have the following functions:
const special_handle= function(err){
console.error("Special Handled",err);
}
const normal_handle= function(err){
console.error("Normal Handled",err);
}
const callback = function(err,mime,data){
if(err) {
if(/*file does not exist*/){
return special_handle(err);
} else {
return normal_handle(err);
}
}
}
fs.readFile(fileFullPath,(err,data)=>{
if(err){
return callback(err);
}
const mimeType = mime.lookup(fileFullPath);
callback(null,mimeType,data);
});
What I want it when the file does not exist to do a special handling instead of do the normal one. But how I will know that the file does not exist over my callback?