mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-03-11 21:38:38 +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 {
|
||||
var url = r.Path
|
||||
if(url === undefined){
|
||||
console.log('UNDEFINED URL',r)
|
||||
}
|
||||
if(this.users[n] != url) this.isUserProfile(url,(isit,err) => {
|
||||
console.log('Could not resolve',n)
|
||||
this.ee.emit('error',r.Message)
|
||||
} else if(this.users[n] != url) this.isUserProfile(url,(isit,err) => {
|
||||
if(isit){
|
||||
console.log(n,'is a user')
|
||||
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) => {
|
||||
if(err) return done(false,err)
|
||||
replyAsObj(r,false,(_,res) => {
|
||||
var v = res.trim()
|
||||
console.log('Version in profile snapshot',addr,'is',v)
|
||||
if(v === this.version)
|
||||
done(true)
|
||||
else
|
||||
done(false,'version mismatch: is "'+v+'" but should be "'+this.version+'"')
|
||||
if(!res || !res.trim){
|
||||
console.log('Could not read version from',addr)
|
||||
} else {
|
||||
var v = res.trim()
|
||||
console.log('Version in profile snapshot',addr,'is',v)
|
||||
if(v === this.version){
|
||||
done(true)
|
||||
} else {
|
||||
done(false,'version mismatch: is "'+v+'" but should be "'+this.version+'"')
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user