Re: Re: Just try

2015-11-01 Thread Dean Landolt
On Fri, Oct 30, 2015 at 2:17 PM, Alican Çubukçuoğlu < alicancubukcuo...@gmail.com> wrote: > The recommended way of checking for file existence in Node.js is calling > `fs.stat()` on the file. If no error was passed to the callback, it exists. > If "ENOENT" was passed, it doesn't. > > If you "promi

Re: Re: Just try

2015-10-30 Thread Alican Çubukçuoğlu
The recommended way of checking for file existence in Node.js is calling `fs.stat()` on the file. If no error was passed to the callback, it exists. If "ENOENT" was passed, it doesn't. If you "promisify" `fs.stat()` and use it with async/await, it throws when a file doesn't exist so you end up wri

Re: Just try

2015-10-30 Thread Michał Wadas
Syntax sugar similar to Go error handling would be much more useful, at least for me : let [err, result] = try JSON.parse('invalid'); On Oct 30, 2015 5:33 PM, "Mohsen Azimi" wrote: > This would be nice with `await` but how would you specify the boundary? > > ``` > let json = try await (await fet

Re: Just try

2015-10-30 Thread Mohsen Azimi
This would be nice with `await` but how would you specify the boundary? ``` let json = try await (await fetch('file'.json).json()); ``` should that throw on `.json()` now? On Fri, Oct 30, 2015 at 6:48 AM Michael McGlothlin < mike.mcgloth...@gmail.com> wrote: > It'd be nice if you could just do t

Just try

2015-10-30 Thread Michael McGlothlin
It'd be nice if you could just do try {} without all the catch and finally stuff because about half the time the logic is simpler if I can just put all the error handling code in one place at the end. I end up with a lot of empty catch (err){} laying around waiting to break something. And using one