DEV Community

Discussion on: `throw` objects and functions

Collapse
aravindballa profile image
Aravind Balla Author

That doesn't have a catch. But it handles it in the then part.

github.com/facebook/react/blob/mas...

Collapse
citizen428 profile image
Michael Kohl

Sure, but that's still very different from your example, which could have been just this:

let value;

// try reading from cache
// if not found, fetch it from external resource
value = read(key);
if (!value) {
  value = fakeExternalRes(key);
  store(key, value);
}

return value;

I understand that examples need to be simplified, I just feel that yours got simplified to the point where it's not actually showing what you intended to anymore.