github.com/blend/go-sdk@v1.20220411.3/examples/db/error/main.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package main
     9  
    10  import (
    11  	"fmt"
    12  	"log"
    13  
    14  	"github.com/blend/go-sdk/db"
    15  )
    16  
    17  func main() {
    18  
    19  	conn, err := db.New(db.OptConfigFromEnv())
    20  	if err != nil {
    21  		log.Fatal(err)
    22  	}
    23  	conn.Open()
    24  
    25  	_, err = conn.Connection.Query("select * from foo")
    26  	fmt.Printf("error: %#v\n", err)
    27  	fmt.Printf("parsed: %#v\n", db.Error(err))
    28  }