Skip to content

How can i check true errors? #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sbslord opened this issue Dec 5, 2014 · 6 comments
Closed

How can i check true errors? #955

sbslord opened this issue Dec 5, 2014 · 6 comments
Labels

Comments

@sbslord
Copy link

sbslord commented Dec 5, 2014

i have a callback function

function(err, result){
    if(err) console.log(this.name + ' mysql callback error: '+err);
}

True error here is a object: who say me table database.user is not exist
but this is a object error and my if is be false so i dont watch the error.
but without if only console.log(err) i see the true error.
how need use? if(typeof err === 'object' || typeof err !== 'undefined') ?

@dougwilson
Copy link
Member

This is a JavaScript language question. The short answer is you only need to do if (err), because err will always be a truthy-value if there is an error and a falsy-value if there is no error.

@sbslord
Copy link
Author

sbslord commented Dec 5, 2014

but not run my console.log and haver error, err is a object and not be true so not enough simple if(err)

@dougwilson
Copy link
Member

All objects in JavaScript are true. There is no object that would be false.

@sbslord
Copy link
Author

sbslord commented Dec 5, 2014

ahh i found the problem when i use console.log(this.name + ' mysql callback error: '+err);
here this.name in my code was my_function.name and i wrote bad my_function and dont get error on console

@sbslord
Copy link
Author

sbslord commented Dec 5, 2014

What better res.send(mysql_error) or console.log(mysql_error) ?
because if have a mysql error the user dont see what the problem and click again and again and be angry

@dougwilson
Copy link
Member

If you are using Express, you should be doing next(err) and letting Express handle the error flow for you.

dveeden pushed a commit to dveeden/mysql that referenced this issue Jan 31, 2023
PR mysqljs#838 introduced a fix for the driver's custom Value Converter that
stopped emitting large uint64 `driver.Value`s as a string. Instead, now
_all_ uint{8,16,32,64} values passed to the driver are returned as
uint64, and `packets.c` now explicitly handles `driver.Value` instances
that are uint64.

However, the update in `packets.c` only applies when sending
`driver.Value` arguments to the server. When a connection is set up
using `InterpolateParams = true` and query interpolation happens inside
of the driver, the `(*mysqlConn) interpolateParams` does **not** handle
uint64 values (which, again, are now passed by `database/sql` because
we've updated our value converter to generate them).

Because of this, any `DB.Query` operations which have an uint argument
(regardless of its size!!) will force the driver to return
`driver.ErrSkip`, disabling client interpolation for such queries.

We can fix this by updating `interpolateParams` like we previously
updated `writeExecutePacket`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants