mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +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::mysql::MySqlQueryAs;
|
||||||
use sqlx::MySqlPool;
|
use sqlx::MySqlPool;
|
||||||
use std::env;
|
use std::env;
|
||||||
@ -18,7 +19,10 @@ enum Command {
|
|||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
#[paw::main]
|
#[paw::main]
|
||||||
async fn main(args: Args) -> anyhow::Result<()> {
|
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 {
|
match args.cmd {
|
||||||
Some(Command::Add { description }) => {
|
Some(Command::Add { description }) => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use anyhow::Context;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use std::env;
|
use std::env;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
@ -17,7 +18,10 @@ enum Command {
|
|||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
#[paw::main]
|
#[paw::main]
|
||||||
async fn main(args: Args) -> anyhow::Result<()> {
|
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 {
|
match args.cmd {
|
||||||
Some(Command::Add { description }) => {
|
Some(Command::Add { description }) => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use anyhow::Context;
|
||||||
use sqlx::sqlite::SqliteQueryAs;
|
use sqlx::sqlite::SqliteQueryAs;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use std::env;
|
use std::env;
|
||||||
@ -18,7 +19,10 @@ enum Command {
|
|||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
#[paw::main]
|
#[paw::main]
|
||||||
async fn main(args: Args) -> anyhow::Result<()> {
|
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 {
|
match args.cmd {
|
||||||
Some(Command::Add { description }) => {
|
Some(Command::Add { description }) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user