Add meaningful errors

This commit is contained in:
PumpkinSeed 2020-05-15 09:06:14 +02:00 committed by Austin Bonander
parent cbccd68963
commit 19edb73ffc
3 changed files with 15 additions and 3 deletions

View File

@ -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 }) => {

View File

@ -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 }) => {

View File

@ -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 }) => {