linkedin / linkedin/dustjs

Thrown exception instead of returning error

Open
#774 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.9k
Forks
461
PR merge metrics
No merged PRs in 30d

Description

The following code throws an uncaught exception:

require("dustjs-linkedin").renderSource("{T}{/T}", {}, function(e, r) { });

Shouldn't dust be catching this exception and passing it into the callback as the first parameter as an error?

/home/sembiance/tmp/dustjs_error/node_modules/dustjs-linkedin/lib/compiler.js:34
      throw new SyntaxError(err.message + ' At line : ' + err.line + ', column : ' + err.column);
      ^

SyntaxError: Expected buffer, comment, end of input, partial, raw, reference, section or special but "{" found. At line : 1, column : 4
    at Object.compiler.compile (/home/sembiance/tmp/dustjs_error/node_modules/dustjs-linkedin/lib/compiler.js:34:13)
    at Object.renderSource (/home/sembiance/tmp/dustjs_error/node_modules/dustjs-linkedin/lib/compiler.js:440:37)
    at Object.<anonymous> (/home/sembiance/tmp/dustjs_error/test.js:1:90)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/compiler.js at compiler.compile line 34 and renderSource line 440, then reproduce the uncaught exception with the code in the issue. Done means the syntax error is passed to the callback as its first argument instead of escaping as an uncaught exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.