github.com/mrqzzz/migrate@v5.1.7+incompatible/database/error.go (about)

     1  package database
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // Error should be used for errors involving queries ran against the database
     8  type Error struct {
     9  	// Optional: the line number
    10  	Line uint
    11  
    12  	// Query is a query excerpt
    13  	Query []byte
    14  
    15  	// Err is a useful/helping error message for humans
    16  	Err string
    17  
    18  	// OrigErr is the underlying error
    19  	OrigErr error
    20  }
    21  
    22  func (e Error) Error() string {
    23  	if len(e.Err) == 0 {
    24  		return fmt.Sprintf("%v in line %v: %s", e.OrigErr, e.Line, e.Query)
    25  	}
    26  	return fmt.Sprintf("%v in line %v: %s (details: %v)", e.Err, e.Line, e.Query, e.OrigErr)
    27  }