mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-09-27 13:01:43 +00:00
Add meaningful errors
This commit is contained in:
parent
cbccd68963
commit
19edb73ffc
@ -1,3 +1,4 @@
|
||||
use anyhow::Context;
|
||||
use sqlx::mysql::MySqlQueryAs;
|
||||
use sqlx::MySqlPool;
|
||||
use std::env;
|
||||
@ -18,7 +19,10 @@ enum Command {
|
||||
#[async_std::main]
|
||||
#[paw::main]
|
||||
async fn main(args: Args) -> anyhow::Result<()> {
|
||||
let pool = MySqlPool::new(&env::var("DATABASE_URL")?).await?;
|
||||
let pool = MySqlPool::new(
|
||||
&env::var("DATABASE_URL").context("`DATABASE_URL` must be set to run this example")?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
match args.cmd {
|
||||
Some(Command::Add { description }) => {
|
||||
|
@ -1,3 +1,4 @@
|
||||
use anyhow::Context;
|
||||
use sqlx::PgPool;
|
||||
use std::env;
|
||||
use structopt::StructOpt;
|
||||
@ -17,7 +18,10 @@ enum Command {
|
||||
#[async_std::main]
|
||||
#[paw::main]
|
||||
async fn main(args: Args) -> anyhow::Result<()> {
|
||||
let mut pool = PgPool::new(&env::var("DATABASE_URL")?).await?;
|
||||
let mut pool = PgPool::new(
|
||||
&env::var("DATABASE_URL").context("`DATABASE_URL` must be set to run this example")?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
match args.cmd {
|
||||
Some(Command::Add { description }) => {
|
||||
|
@ -1,3 +1,4 @@
|
||||
use anyhow::Context;
|
||||
use sqlx::sqlite::SqliteQueryAs;
|
||||
use sqlx::SqlitePool;
|
||||
use std::env;
|
||||
@ -18,7 +19,10 @@ enum Command {
|
||||
#[async_std::main]
|
||||
#[paw::main]
|
||||
async fn main(args: Args) -> anyhow::Result<()> {
|
||||
let pool = SqlitePool::new(&env::var("DATABASE_URL")?).await?;
|
||||
let pool = SqlitePool::new(
|
||||
&env::var("DATABASE_URL").context("`DATABASE_URL` must be set to run this example")?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
match args.cmd {
|
||||
Some(Command::Add { description }) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user