mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-03-12 21:48:39 +01:00
improved error handling
This commit is contained in:
parent
640b14a519
commit
78e78e74fe
@ -100,9 +100,9 @@ BoardsAPI.prototype.resolveIPNS = function(n,handler){
|
|||||||
} else {
|
} else {
|
||||||
var url = r.Path
|
var url = r.Path
|
||||||
if(url === undefined){
|
if(url === undefined){
|
||||||
console.log('UNDEFINED URL',r)
|
console.log('Could not resolve',n)
|
||||||
}
|
this.ee.emit('error',r.Message)
|
||||||
if(this.users[n] != url) this.isUserProfile(url,(isit,err) => {
|
} else if(this.users[n] != url) this.isUserProfile(url,(isit,err) => {
|
||||||
if(isit){
|
if(isit){
|
||||||
console.log(n,'is a user')
|
console.log(n,'is a user')
|
||||||
if(this.users[n] === undefined) this.ee.emit('user',n,url)
|
if(this.users[n] === undefined) this.ee.emit('user',n,url)
|
||||||
@ -127,12 +127,17 @@ BoardsAPI.prototype.isUserProfile = function(addr,done){
|
|||||||
this.ipfs.cat(addr+this.baseurl+'ipfs-boards-version.txt',(err,r) => {
|
this.ipfs.cat(addr+this.baseurl+'ipfs-boards-version.txt',(err,r) => {
|
||||||
if(err) return done(false,err)
|
if(err) return done(false,err)
|
||||||
replyAsObj(r,false,(_,res) => {
|
replyAsObj(r,false,(_,res) => {
|
||||||
|
if(!res || !res.trim){
|
||||||
|
console.log('Could not read version from',addr)
|
||||||
|
} else {
|
||||||
var v = res.trim()
|
var v = res.trim()
|
||||||
console.log('Version in profile snapshot',addr,'is',v)
|
console.log('Version in profile snapshot',addr,'is',v)
|
||||||
if(v === this.version)
|
if(v === this.version){
|
||||||
done(true)
|
done(true)
|
||||||
else
|
} else {
|
||||||
done(false,'version mismatch: is "'+v+'" but should be "'+this.version+'"')
|
done(false,'version mismatch: is "'+v+'" but should be "'+this.version+'"')
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user