mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-19 05:05:46 +00:00
Add meaningful errors
This commit is contained in:
committed by
Austin Bonander
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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user