You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I was testing Promise functionality, then is working just fine, but somehow catch callback is not running.
When I go through the source code, I found this line /NiL.JS/BaseLibrary/Promise.cs is throwing reject error, I test my code with debug mode, the line I found in source code is working, but I got nothing in the terminal, so I'm confused, some help please?
classProgram{staticvoidMain(string[]args){try{varmainModule=newModule("fakedir/superscript.js",@" import fs from ""fs"" fs.readFile(""path/to/file"") .then(res => console.log(res)) .catch(err => console.log(err)) // * this line supposed to log file `${path}` is not found ");mainModule.ModuleResolversChain.Add(newMyTestModuleResolver());mainModule.Run();}catch(Exceptione){Console.WriteLine("Unknown error: "+e);}Console.ReadLine();}}publicsealedclassMyTestModuleResolver:CachedModuleResolverBase{publicoverrideboolTryGetModule(ModuleRequestmoduleRequest,outModuleresult){if(moduleRequest.AbsolutePath=="/fakedir/fs.js"){varmodule=newModule(moduleRequest.AbsolutePath,@" export default { readFile(path, options) { return new Promise((resolve, reject) => { try { if (!io.File.Exists(path)) throw new Error(file `${path}` is not found) const content = io.File.ReadAllText(path) resolve(content) } catch (e) { reject(e) } }) } } ");varnamespaceProvider=newNamespaceProvider("System.IO");module.Context.DefineVariable("io").Assign(namespaceProvider);result=module;returntrue;}result=null;returnfalse;}}
The text was updated successfully, but these errors were encountered:
By the way, I'm trying to wrap some native node.js object into my app, and I think Promise is something in Javascript. And finally seems to missing for a Promise object, normaly a Promise object should have finally method.
constp=Promise.resolve();p.then(()=>{// then stuff }).catch(()=>{// catchstuff }).finally(()=>{// finallystuff })
Today I was testing
Promise
functionality,then
is working just fine, but somehowcatch
callback is not running.When I go through the source code, I found this line /NiL.JS/BaseLibrary/Promise.cs is throwing reject error, I test my code with debug mode, the line I found in source code is working, but I got nothing in the terminal, so I'm confused, some help please?
The text was updated successfully, but these errors were encountered: