haxetink / tink_sql

SQL embedded into Haxe
MIT License
53 stars 16 forks source link

please throw exceptions where it's should throw. #100

Closed sonygod closed 4 years ago

sonygod commented 4 years ago
    var driver = new tink.sql.drivers.MySql({
        host: '1.1.1.1',//it's  wrong ip,and it's should throw exceptions.
        port: 33060,
        user: 'fa_klw',
        password: '123458c'
    });
    db = new Db('fa_klw', driver);//it's should throw exceptions.current seem some where try catch .
back2dos commented 4 years ago

By design, tink libraries do not throw exceptions, but produce errors. You should obtain an error when you start performing queries on the database.

In any case, it would not even be possible to throw an exception there, because connection (or failure to do so) is asynchronous.

The alternative would be to do something like Db.connection('fa_klw', driver) return a promise, that may have the connection error. In that case you'll have one more level of async though.

back2dos commented 4 years ago

If anybody feels strongly about adding an async connection method, please open an issue. Other than that, I consider this issue settled.