Hi ,
I'm trying to use the [WebDav] library (https://github.com/perry-mitchell/webdav-client#readme) and I'm having trouble returning the error (either credentials or url)
The thing is that the example functions, in addition to being asynchronous, are of the type:
const directoryItems = await client.getDirectoryContents ("/");
I want to know if you have experience with asynchronous functions in this environment and how you do this.
I add a couple of examples of how I do this, but ask why I can't return an error
(the msg.client is the client preconfigured on another node)
Example 1 :
const start = async function(a) {
try{
msg.payload = await msg.client.exists(a);
if(msg.payload===true){
node.send([msg,null])
}
else{
node.status({ fill: "yellow", shape: "ring", text: "Does not exists" })
node.send([null,msg])
}
}
catch(err){
error = err
// node.send([null,msg])
// node.error("la dirección no existe")
// throw new Error ( err )
}
}
// Call start
start("/myNextCloudDirectory");
Example 2 :
msg.client.exists("/myNextCloudDirectory")
.then(function(exists) {
msg.exists = exists
if(exists===true){
node.send([msg,null])
}
else{
node.status({ fill: "yellow", shape: "ring", text: "Does not exists" })
node.warn("No existe el directorio")
node.send([null,msg])
}
}).catch(function(e) {
error = err
// node.send([null,msg])
// node.error("la dirección no existe")
// throw new Error ( err )
});
On both catch i cant send or throw anything only node.warn, log or error
(Thanks in advance)