peak-ai / jedlik

DynamoDB ODM for Node
MIT License
106 stars 4 forks source link

Stacktrace doesn't show the line responsible for error #22

Open dnafication opened 4 years ago

dnafication commented 4 years ago

Describe the bug Creating a simple error such as record not found in the table produces error which doesn't show the line responsible for the error message.

To Reproduce or Sample code Steps to reproduce the behavior or a sample code to reproduce it

// index.js file

const jedlik = require("@peak-ai/jedlik");
const Joi = require("joi");

const schema = Joi.object({
  id: Joi.number().required(),
  name: Joi.string().required(),
  type: Joi.string().allow("admin", "user"),
});

const dynamoDBConfig = {
  region: "ap-southeast-2",
  apiVersion: "2012-08-10",
  endpoint: "http://localhost:8000",
};

// the name of the DynamoDB table the model should write to
// it is assumed this table exists
const Users = new jedlik.Model({ table: "users", schema }, dynamoDBConfig);

async function createTableAndQuery() {
  try {
    // query the database for non existent user
    const user2 = await Users.get({ id: 2 });
  } catch (error) {
    console.log(error);
  }
}

createTableAndQuery();

Running the code above produces error:

node index.js

Error: Not Found
    at DynamoDBClient.<anonymous> (/Users/xxx/xxx/try-jedilik/node_modules/@peak-ai/jedlik/dist/dynamodb-client.js:43:23)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/xxx/xxx/try-jedilik/node_modules/@peak-ai/jedlik/dist/dynamodb-client.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Expected behavior It would be beneficial to have the stacktrace display the line responsible for the error at the user code.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.91. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.