mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	KV存储迭代器增加panic处理
This commit is contained in:
		@@ -5,6 +5,7 @@ package kvstore
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type DataType = int
 | 
					type DataType = int
 | 
				
			||||||
@@ -162,7 +163,17 @@ func (this *Query[T]) FieldOffset(fieldOffset []byte) *Query[T] {
 | 
				
			|||||||
//	return this
 | 
					//	return this
 | 
				
			||||||
//}
 | 
					//}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *Query[T]) FindAll(fn IteratorFunc[T]) error {
 | 
					func (this *Query[T]) FindAll(fn IteratorFunc[T]) (err error) {
 | 
				
			||||||
 | 
						defer func() {
 | 
				
			||||||
 | 
							var panicErr = recover()
 | 
				
			||||||
 | 
							if panicErr != nil {
 | 
				
			||||||
 | 
								resultErr, ok := panicErr.(error)
 | 
				
			||||||
 | 
								if ok {
 | 
				
			||||||
 | 
									err = fmt.Errorf("execute query failed: %w", resultErr)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if this.tx != nil {
 | 
						if this.tx != nil {
 | 
				
			||||||
		defer func() {
 | 
							defer func() {
 | 
				
			||||||
			_ = this.tx.Close()
 | 
								_ = this.tx.Close()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user