Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

[xorm.NewEngine] I gave wrong 'dataSourceName' but can't panic the error #1424

Open
conero opened this issue Sep 17, 2019 · 2 comments
Open
Labels

Comments

@conero
Copy link

conero commented Sep 17, 2019

I used xorm to connect Mysql.

// code ....
engine, err := xorm.NewEngine(vtype, dsn)
// dsn is wrong
// but never panic the error 

// I had to check use a SQL like:
md, er := engine.QueryString("select database() as `cdb`, user() as `user`")
// er =>
// `Error 1045: Access denied for user 'root'@'localhost' (using password: YES)`

// code ....

What I gonna to, please give me a hand.

@conero conero changed the title [xorm.NewEngine] I gave wrong 'dataSourceName' but can't panic the error [xorm.NewEngine] I gave wrong 'dataSourceName' but can't panic the error Sep 17, 2019
@lunny
Copy link
Member

lunny commented Sep 17, 2019

You could use engine.Ping to test if the database is alive.

@lunny lunny added the question label Sep 17, 2019
@conero
Copy link
Author

conero commented Sep 17, 2019

@lunny Thanks for your help. But I think engine.Ping isn't direct for the purpose, maybe like IsVaild or Error better. It's a litter proposal for.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants