Skip to content

Commit

Permalink
Spelling fix for example server, better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartArray committed Aug 4, 2020
1 parent 1d4b6f8 commit 75d148d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions examples/serverSkeleton/services/ConstructionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const RosettaSDK = require('../../../..');
* constructionMetadataRequest ConstructionMetadataRequest
* returns ConstructionMetadataResponse
* */
const constructioMetadata = (params) => {
const constructionMetadata = async (params) => {
const { constructionMetadataRequest } = params;
return {};
};
Expand All @@ -42,14 +42,14 @@ const constructioMetadata = (params) => {
* constructionSubmitRequest ConstructionSubmitRequest
* returns ConstructionSubmitResponse
* */
const constructionSubmit = (params) => {
const constructionSubmit = async (params) => {
const { constructionSubmitRequest } = params;
return {};
};

module.exports = {
/* /construction/metadata */
constructioMetadata,
constructionMetadata,

/* /construction/submit */
constructionSubmit,
Expand Down
4 changes: 2 additions & 2 deletions examples/serverSkeleton/services/MempoolService.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const RosettaSDK = require('../../../..');
* mempoolRequest MempoolRequest
* returns MempoolResponse
* */
const mempool = (params) => {
const mempool = async (params) => {
const { mempoolRequest } = params;
return {};
};
Expand All @@ -42,7 +42,7 @@ const mempool = (params) => {
* mempoolTransactionRequest MempoolTransactionRequest
* returns MempoolTransactionResponse
* */
const mempoolTransaction = (params) => {
const mempoolTransaction = async (params) => {
const { mempoolTransactionRequest } = params;
return {};
};
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/CallHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const CallHandler = async function (route, args) {
// Try to call the asserter.
await CallAsserter(asserter, modelName, requestParams);

return await data.handler(args);
return await data.handler(args.params);
};

module.exports = CallHandler;
10 changes: 3 additions & 7 deletions lib/controllers/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Controller {
}

static sendError(response, error) {
console.error(error);

const errResponse = {
code: error.code,
message: error.error || error.message,
Expand Down Expand Up @@ -214,13 +216,7 @@ class Controller {
Controller.sendResponse(response, wrapped, app.config.BEAUTIFY_JSON);

} catch (error) {
// Wrap the error message
const wrapped = Controller.rejectResponse(
error.message || 'Invalid input',
error.code || 405,
);

Controller.sendError(response, wrapped);
Controller.sendError(response, error);
}
}
}
Expand Down

0 comments on commit 75d148d

Please sign in to comment.