Giter Site home page Giter Site logo

Comments (16)

moritz avatar moritz commented on August 17, 2024

👍 to removing both, and just throwing an exception.

Maybe in the long run, we'll want something like a notification system (for errors and other events), but that feels like premature optimization so far.

from dbiish.

asb-capfan avatar asb-capfan commented on August 17, 2024

I tought having the raiserror option would be a good thing as it allows to continue with the program until the programmer decides to handle errors (e.g. log something first).

from dbiish.

pmichaud avatar pmichaud commented on August 17, 2024

A thought from an outside observer: "allows to continue with the program ..." sounds a lot like a Failure object to me. Whatever gets decided should probably follow Perl 6's error handling model and not carry forward Perl 5's.

from dbiish.

mjegh avatar mjegh commented on August 17, 2024

I always set PrintError false and RaiseError true. Why would I want to test every DBI call.

from dbiish.

moritz avatar moritz commented on August 17, 2024

@abraxxa are you going to supply a patch?

from dbiish.

abraxxa avatar abraxxa commented on August 17, 2024

I plan that for after the merge of DBDish::Oracle.

from dbiish.

uberbaud avatar uberbaud commented on August 17, 2024

I'm guessing that the final replacement in the user's code would be something like

use fatal; # replaces RaiseError => 1
...
# replace PrintError => 1
CATCH { when (DBIish::Exception) { .say; .resume; } }

And that works fine, so long as DBIish.pm6 contains something like

class DBIish::Exception is Exception {}

And DBDish.pm6 contains it's own

DBDish::Exception is DBIish::Exception

from which the actual drivers could inherit or just use outright. DBIish must define an Exception class so the user can reference it in and DBDish.pm must also define an Exception class which inherits from DBIish::Exception so the individual Drivers can inherit from them, or the individual drivers must use DBIish;. Both cases seem to me to be a bit of a code smell indicating that the distinction between DBIish and DBDish aren't really reflecting the real world.

So my question is, does there really need to be a separation of DBIish and DBDish, or is that, like the RaiseError/PrintError issue the result of a desire to mimic the perl 5 DBI?

from dbiish.

jonathanstowe avatar jonathanstowe commented on August 17, 2024

I'd say at some point the individual drivers do need to be separated, it's alright with three or four databases but with possibly tens of them (I stopped counting the P5 DBD modules at thirty,) it would become a nightmare of maintenance, plus a barrier to further contribution of drivers.

from dbiish.

uberbaud avatar uberbaud commented on August 17, 2024

I'm sorry, I wasn't at all clear about what I meant. Currently there is a DBIish.pm6 and a DBDish.pm6 (though there isn't an actual perl 5 DBD.pm), and it seems to me that DBDish.pm6 could be folded into DBIish.pm6, and possibly a DBDish.pod if necessary.

I'm guessing that the perl5 DBI/DBD namespace separation was to reserve the DBI namespace entirely for bits and pieces maintained by the DBI folk, while DBD was set aside for stuff that wasn't. And other than the perl6 DBDish.pm that could easily be the case with DBIish/DBDish.

from dbiish.

azawawi avatar azawawi commented on August 17, 2024

@abraxxa any update on DBDish::Oracle?

👍 for throwing exceptions implicitly.

from dbiish.

abraxxa avatar abraxxa commented on August 17, 2024

I've got it working with the 2015.11 release but a bug in the 6.c release (RT#127001) prevents it from functioning with it. All code is at my github fork.

from dbiish.

salortiz avatar salortiz commented on August 17, 2024

The current state of affairs about error handling:

  • Oracle: Simply die on errors inside the driver. The caller needs a CATCH block.
  • All others: die if RaiseError is True, otherwise the errors are ignored even inside the drivers!!!

The methods for error reporting at DBIsh, DBDish's driver level and Connection level ($dbh) are no-ops.

Only at the StatementHandler level ($sth) the user can call the .errstr method to fetch the last error message.

I plan to use and generate X::DBIish::* typed Exception to throw or fail depending on RaiseError or the pragma.

I would like to preserve RaiseError for fine-grained user cases, for example at the prepared statement level.

from dbiish.

salortiz avatar salortiz commented on August 17, 2024

Now DBIish follow Perl 6's model regards exception handling, any additional details can be discussed as subsequent issues.

from dbiish.

jonathanstowe avatar jonathanstowe commented on August 17, 2024

👍

from dbiish.

abraxxa avatar abraxxa commented on August 17, 2024

I still don't see the point why DBIish should follow any stupid Perl 6 DBI API decisions...
Keeping the last exception in an attribute instead of just throwing it makes no sense and will lead to weird bugs and maybe even memory leaks due to circular refs.

from dbiish.

salortiz avatar salortiz commented on August 17, 2024

@abraxxa , We are not here to judge established API decisions, our work is to satisfy users expectations, the more of them, the better.
As documented somewhere else, the Exception throwned we keep for the benefit of the $h.err and $.errstr APIs, is short-lived and replaced (or erased) at the following API call.
If the current implementation, or its current defaults, causes to you or your applications, some issues, please open an specific cause.
(Personally I would have preferred .fail over .trow as default, i.e RaiseErrors => False)

from dbiish.

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.