Skip to content

Commit

Permalink
Merge pull request #83 from JoinColony/fix/catch-a-break
Browse files Browse the repository at this point in the history
We need a `break`!
  • Loading branch information
Christian Maniewski committed Aug 1, 2019
2 parents 5db15e9 + 41a6716 commit 9d2c9f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/IPFSNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ class IPFSNode {
// Don't handle messages from ourselves
if (msg.from === this.id) return;
log('New Message from: %s', msg.from);
log('%O', msg.data);
if (log.enabled) {
// Only stringify when absolutely necessary
log('%O', msg.data.toString());
}
this.events.emit('pubsub:message', msg);
};

Expand Down
18 changes: 14 additions & 4 deletions src/Pinion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ class Pinion {
let action: ClientAction | undefined;
try {
action = JSON.parse(message.data.toString());
} catch (e) {
log('Could not parse pinner message: %O', message.data);
} catch (caughtError) {
if (log.enabled) {
// Only stringify when absolutely necessary
log('Could not parse pinner message: %O', message.data.toString());
}
}

if (!action) return;
Expand All @@ -108,18 +111,25 @@ class Pinion {
} catch (caughtError) {
console.error(caughtError);
}
break;
}
case PIN_HASH: {
if (!ipfsHash) {
log('PIN_HASH: no ipfsHash given: %O', message.data);
if (log.enabled) {
// Only stringify when absolutely necessary
log('PIN_HASH: no ipfsHash given: %O', message.data.toString());
}
return;
}
this.ipfsNode.pinHash(ipfsHash).catch(console.error);
break;
}
case REPLICATE: {
if (!address) {
log('REPLICATE: no address given: %O', message.data);
if (log.enabled) {
// Only stringify when absolutely necessary
log('REPLICATE: no address given: %O', message.data.toString());
}
return;
}
try {
Expand Down

0 comments on commit 9d2c9f6

Please sign in to comment.