zim32 / mysql.dart

MySQL client for Dart written in Dart
BSD 3-Clause "New" or "Revised" License
64 stars 17 forks source link

Throw MySQLException rather than Exception #20

Closed bsutton closed 2 years ago

bsutton commented 2 years ago

Just trying to adapt your library into my package simple_mysql_orm.

Firstly thanks for the work.

One issue I note is that you throw a generic Exception class from the libraries.

I'm wondering if you would consider changing this it a more specific class such as MySQLException as this makes it easier to catch and differentiate from other possible exceptions.

zim32 commented 2 years ago

Hi. I've refactored exceptions. Now all general Exceptions are gone. See https://github.com/zim32/mysql.dart/blob/main/lib/exception.dart what's instead.

bsutton commented 2 years ago

Can I suggest that they all extend a single base class MySqlException.

This will allow a user to catch any of them worth a single catch clause it individual exceptions.

I common error code in the base class would also be useful so you can really detect errors such as login failed, deadlocks etc.

On Mon, 16 May 2022, 9:20 pm zim32, @.***> wrote:

Hi. I've refactored exceptions. Now all general Exceptions are gone. See https://github.com/zim32/mysql.dart/blob/main/lib/exception.dart what's instead.

— Reply to this email directly, view it on GitHub https://github.com/zim32/mysql.dart/issues/20#issuecomment-1127545403, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OBXZUHFDGSPCUSXMMLVKIVOFANCNFSM5V6QLZCA . You are receiving this because you authored the thread.Message ID: @.***>

zim32 commented 2 years ago

Can you see latest code in git and say is it ok now?

bsutton commented 2 years ago

Structure looks good.

Is it possible to extract the SQL error code and make it available in the exception.

i often check for specific error codes

On Wed, 18 May 2022, 4:04 am zim32, @.***> wrote:

Can you see latest code in git and say is it ok now?

— Reply to this email directly, view it on GitHub https://github.com/zim32/mysql.dart/issues/20#issuecomment-1129162989, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32ODHYYXX2WCPEKMTT7TVKPNRTANCNFSM5V6QLZCA . You are receiving this because you authored the thread.Message ID: @.***>

zim32 commented 2 years ago

Nice feature. I will do it

zim32 commented 2 years ago

Server error code is now exposed in MySQLServerException through errorCode prop Release 0.0.19