TritonDataCenter/node-verror

Feature-Request: browser compatibility

mattmeye opened this issue · 10 comments

If i use angular with verror, i get

ERROR in ./node_modules/assert-plus/assert.js
Module not found: Error: Can't resolve 'stream' in '..\myapp\node_modules\assert-plus'

in the compiler

I'm not an expert in the project by any means, but I'm pretty sure that it only supports a NodeJS environment. When you use Angular, you're trying to use verror in a browser environment (which doesn't have modules such as "stream" available). This doesn't look like it's an issue with verror, unless this is meant to be a feature request for implementing a browser version of verror. If that was done, it would probably have to be in a limited form.

It appears actually that the error you're getting isn't even from verror directly but from one of its dependencies. Unless verror switches dependencies or re-implements their own version which doesn't require any node modules, they can't fix this "issue."

yes you are right, i changed the title to a feature request.

Is there any progress on this, would love to use this in an Angular app too!

I don't know of anybody working on it. Sorry.

I opened a PR exactly for that: #59

I just published @openagenda/verror, it's a complete rewrite with some changes:

  • Rewritten with ES classes
  • Is now browser compatible, no more dependencies linking it to Node
  • findCauseByType and hasCauseWithType methods have been added
  • SError class has been removed

https://www.npmjs.com/package/@openagenda/verror

BREAKING CHANGE: The VError creation without new keyword is no longer available.

And I fixed this issue: #78

jfmmm commented

@bertho-zero Your fork on bitbucket seem to be private, unless it was deleted. Can you make that public.

I extracted the repo: https://github.com/Oagenda/verror

I reverted to using prototypes rather than classes so I could create errors without new, like Error.

@bertho-zero any chance you can also add TypeScript types? would be much appreciated

I've never used TypeScript, but someone familiar with it can open a PR.