improve Tangle error messages

This commit is contained in:
Andre Staltz 2024-03-06 11:13:04 +02:00
parent cf1532965e
commit 0c86b43d22
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
2 changed files with 10 additions and 10 deletions

View File

@ -563,8 +563,8 @@ function initDB(peer, config) {
// prettier-ignore
if (err) return cb(new Error('add() failed to remove ghost', { cause: err }))
logAppend(msgID, msg, (err, rec) => {
if (err)
return cb(new Error('add() failed in the log', { cause: err }))
// prettier-ignore
if (err) return cb(new Error('add() failed in the log', { cause: err }))
const doneable = msgsBeingAdded.get(msgID)
msgsBeingAdded.delete(msgID)
queueMicrotask(() => {

View File

@ -145,7 +145,7 @@ class Tangle {
*/
topoSort() {
if (!this.#rootMsg) {
console.trace('Tangle is missing root message')
console.trace(`Tangle "${this.#rootID}" is missing root message`)
return []
}
const sorted = []
@ -164,7 +164,7 @@ class Tangle {
*/
get tips() {
if (!this.#rootMsg) {
console.trace('Tangle is missing root message')
console.trace(`Tangle "${this.#rootID}" is missing root message`)
return new Set()
}
return this.#tips
@ -176,7 +176,7 @@ class Tangle {
*/
getLipmaaSet(depth) {
if (!this.#rootMsg) {
console.trace('Tangle is missing root message')
console.trace(`Tangle "${this.#rootID}" is missing root message`)
return new Set()
}
const lipmaaDepth = lipmaa(depth + 1) - 1
@ -201,7 +201,7 @@ class Tangle {
#isFeed() {
if (!this.#rootMsg) {
console.trace('Tangle is missing root message')
console.trace(`Tangle "${this.#rootID}" is missing root message`)
return false
}
return isMoot(this.#rootMsg)
@ -214,7 +214,7 @@ class Tangle {
get mootDetails() {
if (!this.#isFeed()) return null
if (!this.#rootMsg) {
console.trace('Tangle is missing root message')
console.trace(`Tangle "${this.#rootID}" is missing root message`)
return null
}
const { account, domain } = this.#rootMsg.metadata
@ -226,7 +226,7 @@ class Tangle {
*/
get type() {
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.#rootMsg.metadata.account === 'self') return 'account'
@ -245,7 +245,7 @@ class Tangle {
*/
shortestPathToRoot(msgID) {
if (!this.#rootMsg) {
console.trace('Tangle is missing root message')
console.trace(`Tangle "${this.#rootID}" is missing root message`)
return []
}
const path = []
@ -301,7 +301,7 @@ class Tangle {
*/
precedes(msgAID, msgBID) {
if (!this.#rootMsg) {
console.trace('Tangle is missing root message')
console.trace(`Tangle "${this.#rootID}" is missing root message`)
return false
}
if (msgAID === msgBID) return false