Git Product home page Git Product logo

Comments (12)

brainkim avatar brainkim commented on May 28, 2024

Can you go a little bit more into how these errors would be used in relation to the Channel API? For instance, are you saying that calls to Channel.prototype.next should reject with these errors? Or that you should be able to throw these errors in the channel executor to modify the channel somehow?

from repeater.

elderapo avatar elderapo commented on May 28, 2024

I just saw an error like this one here. From my experience, it is a good habit to throw errors that can be easily handled using instanceof operator just in case a very specific error handling needs to be done.

from repeater.

brainkim avatar brainkim commented on May 28, 2024

Ahhhh. Sure that makes sense. Actually though, channels will never remove from a buffer when it is empty or add to a buffer when it is full, so those errors were really just for development usage. I would not be opposed to using a more descriptive error class however. I actually make sure to use Error subclasses for errors which I think will be exposed to the user. ChannelOverflowErrors for instance: https://github.com/channeljs/channel/blob/master/packages/channel/src/channel.ts#L5-L18

from repeater.

elderapo avatar elderapo commented on May 28, 2024

I didn't see that. I think using ts-custom-error package is a good idea anyways because writing error classes in typescript is a messy and very error-prone process (easy to forget fixing the prototype etc).

Adding ts-custom-error would make @channel/channel not dependency-free anymore so I am not sure how you feel about that. If you decide that this is fine let me know and I will gladly submit a pull request.

from repeater.

brainkim avatar brainkim commented on May 28, 2024

Adding ts-custom-error would make @channel/channel not dependency-free anymore

Haha yeah it might sound silly but I’d rather not add a dependency so long as we can avoid it. Also I just wish there was a global CustomError class that you could subclass without worry. Maybe we can refactor all the custom errors to use a copy-pasted fork of ts-custom-error? Maybe I should just let this dependency in. I dunno haha.

from repeater.

elderapo avatar elderapo commented on May 28, 2024

I've been using it in most of my projects. It works just fine, code is clean and well tested and it doesn't have any dependencies. I don't see why not tbh.

from repeater.

brainkim avatar brainkim commented on May 28, 2024

I’m leaning towards sure why not!

from repeater.

threeid avatar threeid commented on May 28, 2024

I think devDependencies is fine. Since i don't use Typescript, i vote for No.

from repeater.

elderapo avatar elderapo commented on May 28, 2024

You can't put runtime libraries into devDependencies because it would crash your program.

from repeater.

brainkim avatar brainkim commented on May 28, 2024

You can't put runtime libraries into devDependencies because it would crash your program.

Is this true if you bundle the dependency with rollup? We’re currently using rollup-plugin-typescript2 to bundle packages and I’m wondering if rollup can bundle devDependencies to effectively erase the dependency from the npm dependency tree.

from repeater.

elderapo avatar elderapo commented on May 28, 2024

I am not sure but it does not sound like a great idea tbh. Even if it worked it wouldn't make much sense to do so because it would cause ts-custom-error to get bundled multiple times if used from the main app as well.

from repeater.

brainkim avatar brainkim commented on May 28, 2024

See #27 (comment): I think it’s unnecessary for now. Might accept more narrowly scoped PRs for subclassing Buffer errors if there is a clear use-case but only Channels should really be consuming buffers anyways.

from repeater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.