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) {
if obj.loading != nil {
obj.mu.Unlock()
panic(fmt.Sprintf("%s(%s): activate: need to load, but .loading != nil",
obj.zclass.class, obj.oid))
panic(obj.badf("activate: need to load, but .loading != nil"))
}
// we become responsible for loading the object
......@@ -166,9 +165,8 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
if l, s := obj.loading, obj.state; !(l == loading && s == GHOST) {
obj.mu.Unlock()
panic(fmt.Sprintf("%s(%s): activate: after load: object state unexpected: " +
"%v (want %v); .loading = %p (want %p)",
obj.zclass.class, obj.oid, s, GHOST, l, loading))
panic(obj.badf("activate: after load: object state unexpected: " +
"%v (want %v); .loading = %p (want %p)", s, GHOST, l, loading))
}
obj.serial = serial
......@@ -185,7 +183,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
xerr.Context(&err, "pysetstate")
default:
panic("!stateful instance")
panic(obj.badf("activate: !stateful instance"))
}
state.Release()
......@@ -194,6 +192,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
}
}
// XXX set state to load error?
loading.err = err
obj.mu.Unlock()
......@@ -209,7 +208,7 @@ func (obj *Persistent) PDeactivate() {
obj.refcnt--
if obj.refcnt < 0 {
panic("deactivate: refcnt < 0")
panic(obj.badf("deactivate: refcnt < 0"))
}
if obj.refcnt > 0 {
return // users still left
......@@ -243,7 +242,7 @@ func (obj *Persistent) PInvalidate() {
if obj.refcnt != 0 {
// object is currently in use
panic("invalidate: refcnt != 0")
panic(obj.badf("invalidate: refcnt != 0")) // XXX
}
obj.serial = InvalidTid
......@@ -261,6 +260,13 @@ func (obj *Persistent) istate() 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 ----
// 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