Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

fix: Return swarm http errors as json #1196

Merged
merged 2 commits into from
Feb 15, 2018
Merged

fix: Return swarm http errors as json #1196

merged 2 commits into from
Feb 15, 2018

Conversation

paulogr
Copy link
Contributor

@paulogr paulogr commented Jan 29, 2018

Closes #1176

Returning errors as json the cli now receives treated messages as bellow:

/Users/paulogr/dev/js-ipfs/src/cli/commands/swarm/connect.js:20
        throw err
        ^

Error: no protocol with name: libp2p-webrtc-star
    at parseError (/Users/paulogr/dev/js-ipfs/node_modules/ipfs-api/src/utils/send-request.js:16:17)
    at ClientRequest.<anonymous> (/Users/paulogr/dev/js-ipfs/node_modules/ipfs-api/src/utils/send-request.js:39:14)
    at Object.onceWrapper (events.js:255:19)
    at ClientRequest.emit (events.js:160:13)

@@ -10,13 +10,22 @@ exports = module.exports
// common pre request handler that parses the args and returns `addr` which is assigned to `request.pre.args`
exports.parseAddrs = (request, reply) => {
if (!request.query.arg) {
return reply("Argument 'addr' is required").code(400).takeover()
const err = 'Argument \'addr\' is required'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use '``' instead? Argument 'addr' is required - should work without needing to escape anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @dryajov

@daviddias daviddias merged commit 68e7b5a into ipfs:master Feb 15, 2018
@daviddias
Copy link
Member

Thanks @paulogr :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants