mirror of https://codeberg.org/pzp/pzp-db.git
improve Tangle error messages
This commit is contained in:
parent
cf1532965e
commit
0c86b43d22
|
@ -563,8 +563,8 @@ function initDB(peer, config) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
if (err) return cb(new Error('add() failed to remove ghost', { cause: err }))
|
if (err) return cb(new Error('add() failed to remove ghost', { cause: err }))
|
||||||
logAppend(msgID, msg, (err, rec) => {
|
logAppend(msgID, msg, (err, rec) => {
|
||||||
if (err)
|
// prettier-ignore
|
||||||
return cb(new Error('add() failed in the log', { cause: err }))
|
if (err) return cb(new Error('add() failed in the log', { cause: err }))
|
||||||
const doneable = msgsBeingAdded.get(msgID)
|
const doneable = msgsBeingAdded.get(msgID)
|
||||||
msgsBeingAdded.delete(msgID)
|
msgsBeingAdded.delete(msgID)
|
||||||
queueMicrotask(() => {
|
queueMicrotask(() => {
|
||||||
|
|
|
@ -145,7 +145,7 @@ class Tangle {
|
||||||
*/
|
*/
|
||||||
topoSort() {
|
topoSort() {
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
console.trace('Tangle is missing root message')
|
console.trace(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
const sorted = []
|
const sorted = []
|
||||||
|
@ -164,7 +164,7 @@ class Tangle {
|
||||||
*/
|
*/
|
||||||
get tips() {
|
get tips() {
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
console.trace('Tangle is missing root message')
|
console.trace(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
return new Set()
|
return new Set()
|
||||||
}
|
}
|
||||||
return this.#tips
|
return this.#tips
|
||||||
|
@ -176,7 +176,7 @@ class Tangle {
|
||||||
*/
|
*/
|
||||||
getLipmaaSet(depth) {
|
getLipmaaSet(depth) {
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
console.trace('Tangle is missing root message')
|
console.trace(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
return new Set()
|
return new Set()
|
||||||
}
|
}
|
||||||
const lipmaaDepth = lipmaa(depth + 1) - 1
|
const lipmaaDepth = lipmaa(depth + 1) - 1
|
||||||
|
@ -201,7 +201,7 @@ class Tangle {
|
||||||
|
|
||||||
#isFeed() {
|
#isFeed() {
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
console.trace('Tangle is missing root message')
|
console.trace(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return isMoot(this.#rootMsg)
|
return isMoot(this.#rootMsg)
|
||||||
|
@ -214,7 +214,7 @@ class Tangle {
|
||||||
get mootDetails() {
|
get mootDetails() {
|
||||||
if (!this.#isFeed()) return null
|
if (!this.#isFeed()) return null
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
console.trace('Tangle is missing root message')
|
console.trace(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const { account, domain } = this.#rootMsg.metadata
|
const { account, domain } = this.#rootMsg.metadata
|
||||||
|
@ -226,7 +226,7 @@ class Tangle {
|
||||||
*/
|
*/
|
||||||
get type() {
|
get type() {
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
throw new Error('Tangle is missing root message')
|
throw new Error(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
}
|
}
|
||||||
if (this.#isFeed()) return 'feed'
|
if (this.#isFeed()) return 'feed'
|
||||||
if (this.#rootMsg.metadata.account === 'self') return 'account'
|
if (this.#rootMsg.metadata.account === 'self') return 'account'
|
||||||
|
@ -245,7 +245,7 @@ class Tangle {
|
||||||
*/
|
*/
|
||||||
shortestPathToRoot(msgID) {
|
shortestPathToRoot(msgID) {
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
console.trace('Tangle is missing root message')
|
console.trace(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
const path = []
|
const path = []
|
||||||
|
@ -301,7 +301,7 @@ class Tangle {
|
||||||
*/
|
*/
|
||||||
precedes(msgAID, msgBID) {
|
precedes(msgAID, msgBID) {
|
||||||
if (!this.#rootMsg) {
|
if (!this.#rootMsg) {
|
||||||
console.trace('Tangle is missing root message')
|
console.trace(`Tangle "${this.#rootID}" is missing root message`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (msgAID === msgBID) return false
|
if (msgAID === msgBID) return false
|
||||||
|
|
Loading…
Reference in New Issue