本文整理匯總了Golang中github.com/coocood/qbs.Qbs.Rollback方法的典型用法代碼示例。如果您正苦於以下問題:Golang Qbs.Rollback方法的具體用法?Golang Qbs.Rollback怎麽用?Golang Qbs.Rollback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coocood/qbs.Qbs
的用法示例。
在下文中一共展示了Qbs.Rollback方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandlePanic
//HandlePanic rolls back the transiction provided and then panics again.
func (self *QbsDefaultOrmTransactionPolicy) HandlePanic(tx *qbs.Qbs, err interface{}) (interface{}, error) {
log.Printf("got panic, rolling back and returning 500 to client (%v)\n", err)
if rerr := tx.Rollback(); rerr != nil {
panic(rerr)
}
return nil, HTTPError(http.StatusInternalServerError, fmt.Sprintf("panic: %v", err))
}
示例2: HandleResult
//HandleResult determines whether or not the transaction provided should be rolled
//back or if it should be committed. It rolls back when the result value is
//a non-http error, if it is an Error and the status code is >= 400.
func (self *QbsDefaultOrmTransactionPolicy) HandleResult(tx *qbs.Qbs, value interface{}, err error) (interface{}, error) {
if err != nil {
switch e := err.(type) {
case *Error:
if e.StatusCode >= 400 {
rerr := tx.Rollback()
if rerr != nil {
return nil, rerr
}
}
default:
rerr := tx.Rollback()
if rerr != nil {
return nil, rerr
}
return nil, HTTPError(http.StatusInternalServerError, fmt.Sprintf("%v", err))
}
} else {
if cerr := tx.Commit(); cerr != nil {
return nil, cerr
}
}
return value, err
}