Commit 7b0de48a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f96736a2
...@@ -149,8 +149,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) { ...@@ -149,8 +149,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
if obj.loading != nil { if obj.loading != nil {
obj.mu.Unlock() obj.mu.Unlock()
panic(fmt.Sprintf("%s(%s): activate: need to load, but .loading != nil", panic(obj.badf("activate: need to load, but .loading != nil"))
obj.zclass.class, obj.oid))
} }
// we become responsible for loading the object // we become responsible for loading the object
...@@ -166,9 +165,8 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) { ...@@ -166,9 +165,8 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
if l, s := obj.loading, obj.state; !(l == loading && s == GHOST) { if l, s := obj.loading, obj.state; !(l == loading && s == GHOST) {
obj.mu.Unlock() obj.mu.Unlock()
panic(fmt.Sprintf("%s(%s): activate: after load: object state unexpected: " + panic(obj.badf("activate: after load: object state unexpected: " +
"%v (want %v); .loading = %p (want %p)", "%v (want %v); .loading = %p (want %p)", s, GHOST, l, loading))
obj.zclass.class, obj.oid, s, GHOST, l, loading))
} }
obj.serial = serial obj.serial = serial
...@@ -185,7 +183,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) { ...@@ -185,7 +183,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
xerr.Context(&err, "pysetstate") xerr.Context(&err, "pysetstate")
default: default:
panic("!stateful instance") panic(obj.badf("activate: !stateful instance"))
} }
state.Release() state.Release()
...@@ -194,6 +192,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) { ...@@ -194,6 +192,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
} }
} }
// XXX set state to load error?
loading.err = err loading.err = err
obj.mu.Unlock() obj.mu.Unlock()
...@@ -209,7 +208,7 @@ func (obj *Persistent) PDeactivate() { ...@@ -209,7 +208,7 @@ func (obj *Persistent) PDeactivate() {
obj.refcnt-- obj.refcnt--
if obj.refcnt < 0 { if obj.refcnt < 0 {
panic("deactivate: refcnt < 0") panic(obj.badf("deactivate: refcnt < 0"))
} }
if obj.refcnt > 0 { if obj.refcnt > 0 {
return // users still left return // users still left
...@@ -243,7 +242,7 @@ func (obj *Persistent) PInvalidate() { ...@@ -243,7 +242,7 @@ func (obj *Persistent) PInvalidate() {
if obj.refcnt != 0 { if obj.refcnt != 0 {
// object is currently in use // object is currently in use
panic("invalidate: refcnt != 0") panic(obj.badf("invalidate: refcnt != 0")) // XXX
} }
obj.serial = InvalidTid obj.serial = InvalidTid
...@@ -261,6 +260,13 @@ func (obj *Persistent) istate() Ghostable { ...@@ -261,6 +260,13 @@ func (obj *Persistent) istate() Ghostable {
return xstateful.Interface().(Ghostable) return xstateful.Interface().(Ghostable)
} }
// badf returns formatted error prefixed with obj's class and oid.
func (obj *Persistent) badf(format string, argv ...interface{}) error {
return fmt.Errorf("%s(%s): " + format,
append([]interface{}{obj.zclass.class, obj.oid}, argv...))
}
// ---- class <-> type; new ghost ---- // ---- class <-> type; new ghost ----
// zclass describes one ZODB class in relation to a Go type. // zclass describes one ZODB class in relation to a Go type.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment