Coder Social home page Coder Social logo

Comments (6)

oles avatar oles commented on July 18, 2024 2

I see, I may be thinking about this wrong.

I'd like to see what caused the error, as I think the ConnectionRefused is too vague. Perhaps it's better to add some details to it instead.

The more I think about it, the more it makes sense for Postgres.js to instead add a cause to its error(s) and wrap the ConnectionRefused 🤔

from deno.

bartlomieju avatar bartlomieju commented on July 18, 2024 1

@oles I'm still not sure how that would work - the error you see above is an instance of Deno.errors.ConnectionRefused. The way it is constructed is that when a relevant native (Rust) API raises it, it's translated to that instance. There's no underlying "cause" or other error that could be "linked".

I think I'm missing a point here, so any further explanation would be helpful 😅

from deno.

bartlomieju avatar bartlomieju commented on July 18, 2024

What would the cause be set it?

from deno.

oles avatar oles commented on July 18, 2024

Based on the stack trace, I think it should be the cachedError - the error just before ConnectionRefused is thrown - but I'm not fully sure.

I've at least written code before that was similar to the currently first MDN example, which would result in what I think - it seems.

try {
  connectToDatabase();
} catch (err) {
  throw new Error("Connecting to database failed.", { cause: err });
}

from deno.

bartlomieju avatar bartlomieju commented on July 18, 2024

Sorry I'm a bit confused here. Is this issue about adding cause field to all instance of Deno.errors.* classes? Or is it about the fact that if you pass one of these instances to { cause: err} it doesn't work properly?

from deno.

oles avatar oles commented on July 18, 2024

Sorry for the confusion! I could likely have been clearer.

Adding a cause field to all instances of the Deno.errors.* is what I mean, yes :)

from deno.

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.