Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling for compile errors #163

Open
aileen opened this issue Sep 12, 2018 · 0 comments
Open

Better error handling for compile errors #163

aileen opened this issue Sep 12, 2018 · 0 comments

Comments

@aileen
Copy link
Member

aileen commented Sep 12, 2018

When running into an Handlebars error, GScan doesn't really tell you what went wrong.

GScan renders an error like that:

Uh-Oh, There was an error.
Cannot read property 'push' of undefined

TypeError: Cannot read property 'push' of undefined at /opt/gscan/releases/2018-09-06T12:20:32.572Z/lib/format.js:60:38 at /opt/gscan/shared/node_modules/lodash/lodash.js:4925:15 at baseForOwn (/opt/gscan/shared/node_modules/lodash/lodash.js:3010:24) at /opt/gscan/shared/node_modules/lodash/lodash.js:4894:18 at Function.forEach (/opt/gscan/shared/node_modules/lodash/lodash.js:9342:14) at Object.format (/opt/gscan/releases/2018-09-06T12:20:32.572Z/lib/format.js:52:7) at doRender (/opt/gscan/releases/2018-09-06T12:20:32.572Z/app/index.js:80:30) at Layer.handle [as handle_request] (/opt/gscan/shared/node_modules/express/lib/router/layer.js:95:5) at next (/opt/gscan/shared/node_modules/express/lib/router/route.js:137:13) at /opt/gscan/releases/2018-09-06T12:20:32.572Z/app/index.js:68:32 at PassThroughHandlerContext.finallyHandler (/opt/gscan/shared/node_modules/bluebird/js/release/finally.js:56:23) at PassThroughHandlerContext.tryCatcher (/opt/gscan/shared/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/opt/gscan/shared/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/opt/gscan/shared/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/opt/gscan/shared/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/opt/gscan/shared/node_modules/bluebird/js/release/promise.js:693:18)

Which was - in this case - caused by opening with {{primary_author}}, but closing with {{/author}}. This should be detected and better communicated.

kevinansfield added a commit to kevinansfield/gscan that referenced this issue Apr 16, 2019
refs TryGhost#163
- catch an error from the parse step and push it into the returned messages as a fatal error

Invalid file `test.hbs`:
```hbs
{{#primary_author}}
    {{name}}
{{/author}}
```

Resulting message:
```
[
  {
    "moduleId": "test.hbs",
    "message": "primary_author doesn't match author - 1:3",
    "fatal": true,
    "column": 3,
    "line": 1
  }
]
```
kevinansfield added a commit to kevinansfield/gscan that referenced this issue Jul 25, 2019
refs TryGhost#163
- catch an error from the parse step and push it into the returned messages as a fatal error

Invalid file `test.hbs`:
```hbs
{{#primary_author}}
    {{name}}
{{/author}}
```

Resulting message:
```
[
  {
    "moduleId": "test.hbs",
    "message": "primary_author doesn't match author - 1:3",
    "fatal": true,
    "column": 3,
    "line": 1
  }
]
```
naz pushed a commit to kevinansfield/gscan that referenced this issue Oct 23, 2019
refs TryGhost#163
- catch an error from the parse step and push it into the returned messages as a fatal error

Invalid file `test.hbs`:
```hbs
{{#primary_author}}
    {{name}}
{{/author}}
```

Resulting message:
```
[
  {
    "moduleId": "test.hbs",
    "message": "primary_author doesn't match author - 1:3",
    "fatal": true,
    "column": 3,
    "line": 1
  }
]
```
naz pushed a commit that referenced this issue Oct 29, 2019
refs https://github.com/TryGhost/gscan/issues/265
refs #163

- Initial AST linter spike
- Add basic handling of parse errors to AST linter
- catch an error from the parse step and push it into the returned messages as a fatal error

Invalid file `test.hbs`:
```hbs
{{#primary_author}}
    {{name}}
{{/author}}
```

Resulting message:
```
[
  {
    "moduleId": "test.hbs",
    "message": "primary_author doesn't match author - 1:3",
    "fatal": true,
    "column": 3,
    "line": 1
  }
]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant