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

Improve the error message to find where the error occurred #57

Open
unit-404 opened this issue Apr 6, 2024 · 2 comments
Open

Improve the error message to find where the error occurred #57

unit-404 opened this issue Apr 6, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@unit-404
Copy link

unit-404 commented Apr 6, 2024

I can't even figure out anything, which pug file has the error, where the error is, who caused it, or what caused it. I can't even physically find it or calculate it, because the specific source is almost never given. So I am misled and extremely confused. Because of this, I am forced to just frantically and in a panic to look for any possible source of this problem.

And it tends to arise because of this kind of design...

something
  if block
    block
  else
    #{""}

And it seems like the design may not have a visual effect at all.

something
  // v1 
  block()

  // may be, may not work
  if block
    block()
  else
    #{""}

And I have previously, in one form or another, had similar problems.

ERROR in   Error: Child compilation failed:
  Module build failed (from ./node_modules/@webdiscus/pug-loader/src/index.js):
  Error: PugLoaderException:
  [pug-loader] Failed to execute template function.
  Template file: C:\Frontend\IDX-L1-U\src\index.pug

  Original Error:
  TypeError: Cannot read properties of undefined (reading 'call')
      at Object.compile (C:\Frontend\IDX-L1-U\webpack\node_modules\@webdiscus\pug-loader\src\index.js:283:26)
      at module.exports (C:\Frontend\IDX-L1-U\webpack\node_modules\@webdiscus\pug-loader\src\index.js:297:11)
  ModuleBuildError: Module build failed (from ./node_modules/@webdiscus/pug-loader/src/index.js):
  Error: PugLoaderException:
  [pug-loader] Failed to execute template function.
  Template file: C:\Frontend\IDX-L1-U\src\index.pug

  Original Error:
  TypeError: Cannot read properties of undefined (reading 'call')
      at Object.compile (C:\Frontend\IDX-L1-U\webpack\node_modules\@webdiscus\pug-loader\src\index.js:283:26)
      at module.exports (C:\Frontend\IDX-L1-U\webpack\node_modules\@webdiscus\pug-loader\src\index.js:297:11)
      at processResult (C:\Frontend\IDX-L1-U\webpack\node_modules\webpack\lib\NormalModule.js:841:19)
      at C:\Frontend\IDX-L1-U\webpack\node_modules\webpack\lib\NormalModule.js:966:5
      at C:\Frontend\IDX-L1-U\webpack\node_modules\loader-runner\lib\LoaderRunner.js:400:11
      at C:\Frontend\IDX-L1-U\webpack\node_modules\loader-runner\lib\LoaderRunner.js:252:18
      at context.callback (C:\Frontend\IDX-L1-U\webpack\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
      at C:\Frontend\IDX-L1-U\webpack\node_modules\@webdiscus\pug-loader\src\index.js:300:46
      at Object.compile (C:\Frontend\IDX-L1-U\webpack\node_modules\@webdiscus\pug-loader\src\index.js:284:5)
      at module.exports (C:\Frontend\IDX-L1-U\webpack\node_modules\@webdiscus\pug-loader\src\index.js:297:11)
      at LOADER_EXECUTION (C:\Frontend\IDX-L1-U\webpack\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
      at runSyncOrAsync (C:\Frontend\IDX-L1-U\webpack\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
      at iterateNormalLoaders (C:\Frontend\IDX-L1-U\webpack\node_modules\loader-runner\lib\LoaderRunner.js:251:2)
      at C:\Frontend\IDX-L1-U\webpack\node_modules\loader-runner\lib\LoaderRunner.js:224:4
      at C:\Frontend\IDX-L1-U\webpack\node_modules\webpack\lib\NormalModule.js:920:15
      at Array.eval (eval at create (C:\Frontend\IDX-L1-U\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <a  nonymous>:12:1)
      at runCallbacks (C:\Frontend\IDX-L1-U\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:45:15)
      at C:\Frontend\IDX-L1-U\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:279:5
      at C:\Frontend\IDX-L1-U\webpack\node_modules\graceful-fs\graceful-fs.js:123:16
      at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)

  - index.js:283 Object.compile
    [webpack]/[@webdiscus]/pug-loader/src/index.js:283:26

  - index.js:297 module.exports
    [webpack]/[@webdiscus]/pug-loader/src/index.js:297:11

  - ModuleBuildError: Module build failed (from ./node_modules/@webdiscus/pug-loader/src/index.js):

  - Error: PugLoaderException:

  - [pug-loader] Failed to execute template function.

  - Template file: C:\Frontend\IDX-L1-U\src\index.pug

  - Original Error:

  - TypeError: Cannot read properties of undefined (reading 'call')

  - index.js:283 Object.compile
    [webpack]/[@webdiscus]/pug-loader/src/index.js:283:26

  - index.js:297 module.exports
    [webpack]/[@webdiscus]/pug-loader/src/index.js:297:11

  - NormalModule.js:841 processResult
    [webpack]/[webpack]/lib/NormalModule.js:841:19

  - NormalModule.js:966
    [webpack]/[webpack]/lib/NormalModule.js:966:5

  - LoaderRunner.js:400
    [webpack]/[loader-runner]/lib/LoaderRunner.js:400:11

  - LoaderRunner.js:252
    [webpack]/[loader-runner]/lib/LoaderRunner.js:252:18

  - LoaderRunner.js:124 context.callback
    [webpack]/[loader-runner]/lib/LoaderRunner.js:124:13

  - index.js:300
    [webpack]/[@webdiscus]/pug-loader/src/index.js:300:46

  - index.js:284 Object.compile
    [webpack]/[@webdiscus]/pug-loader/src/index.js:284:5

  - index.js:297 module.exports
    [webpack]/[@webdiscus]/pug-loader/src/index.js:297:11

  - LoaderRunner.js:132 LOADER_EXECUTION
    [webpack]/[loader-runner]/lib/LoaderRunner.js:132:14

  - LoaderRunner.js:133 runSyncOrAsync
    [webpack]/[loader-runner]/lib/LoaderRunner.js:133:4

  - LoaderRunner.js:251 iterateNormalLoaders
    [webpack]/[loader-runner]/lib/LoaderRunner.js:251:2

  - LoaderRunner.js:224
    [webpack]/[loader-runner]/lib/LoaderRunner.js:224:4

  - NormalModule.js:920
    [webpack]/[webpack]/lib/NormalModule.js:920:15


  - CachedInputFileSystem.js:45 runCallbacks
    [webpack]/[enhanced-resolve]/lib/CachedInputFileSystem.js:45:15

  - CachedInputFileSystem.js:279
    [webpack]/[enhanced-resolve]/lib/CachedInputFileSystem.js:279:5

  - graceful-fs.js:123
    [webpack]/[graceful-fs]/graceful-fs.js:123:16

  - context:68 FSReqCallback.readFileAfterClose [as oncomplete]
    node:internal/fs/read/context:68:3

  - child-compiler.js:174
    [webpack]/[html-webpack-plugin]/lib/child-compiler.js:174:18

  - Compiler.js:605 finalCallback
    [webpack]/[webpack]/lib/Compiler.js:605:5

  - Compiler.js:640
    [webpack]/[webpack]/lib/Compiler.js:640:11

  - Compiler.js:1329
    [webpack]/[webpack]/lib/Compiler.js:1329:17


  - Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
    [webpack]/[tapable]/lib/Hook.js:18:14

  - Compiler.js:1325
    [webpack]/[webpack]/lib/Compiler.js:1325:33

  - Compilation.js:2900 finalCallback
    [webpack]/[webpack]/lib/Compilation.js:2900:11

  - Compilation.js:3209
    [webpack]/[webpack]/lib/Compilation.js:3209:11


  - Hook.js:18 Hook.CALL_ASYNC_DELEGATE [as _callAsync]
    [webpack]/[tapable]/lib/Hook.js:18:14

  - Compilation.js:3202
    [webpack]/[webpack]/lib/Compilation.js:3202:38


  - Compilation.js:529
    [webpack]/[webpack]/lib/Compilation.js:529:10

  - SourceMapDevToolPlugin.js:588
    [webpack]/[webpack]/lib/SourceMapDevToolPlugin.js:588:10

  - async.js:2830
    [webpack]/[neo-async]/async.js:2830:7

  - async.js:2857 Object.each
    [webpack]/[neo-async]/async.js:2857:9

  - SourceMapDevToolPlugin.js:412
    [webpack]/[webpack]/lib/SourceMapDevToolPlugin.js:412:17

  - async.js:2830
    [webpack]/[neo-async]/async.js:2830:7

  - async.js:2857 Object.each
    [webpack]/[neo-async]/async.js:2857:9

  - SourceMapDevToolPlugin.js:231
    [webpack]/[webpack]/lib/SourceMapDevToolPlugin.js:231:15

  - Compilation.js:517 fn
    [webpack]/[webpack]/lib/Compilation.js:517:9




webpack 5.91.0 compiled with 1 error in 127 ms

Main and general issue: (in some cases) misinformation and misrepresentation.

Resolved?
And yet my mistake has been identified, it has to do with the wrong mixin name. But it still does not cancel the fact that you can easily get lost and confused about what happened.

@webdiscus
Copy link
Owner

webdiscus commented Apr 6, 2024

Hallo @unit-404,

I can not reproduce your error message.
Can you please create small complete repo (package.json, webpack config, etc) with your issue message.

Following example:
index.pug

something
  if block
    block
  else
    #{""}

Generate the error message:

ERROR in ./src/index.pug           <== Exact in this FILE is an issue
Module build failed (from ../../../src/index.js):
Error:·
[pug-loader] Pug compilation failed.
Error: /Users/xxx/webpack/pug-loader/test/cases/exception-evaluate-template2/src/index.pug:6:5
    4| something
    5|   if block
  > 6|     block.                  <== Exact here is the problem
-----------^
    7|   else
    8|     #{\"\"}·
Anonymous blocks are not allowed unless they are part of a mixin.
    at Object.compile (/Users/xxx/webpack/pug-loader/src/index.js:272:26)
    at Object.call (/Users/xxx/webpack/pug-loader/src/index.js:297:11)·
webpack 5.90.1 compiled with 1 error in 176 ms"

@webdiscus webdiscus changed the title No exact information when got such error... Improve the error message to find where the error occurred Apr 6, 2024
@webdiscus webdiscus added the enhancement New feature or request label Apr 6, 2024
@unit-404
Copy link
Author

unit-404 commented Apr 7, 2024

Wait some week, I try to find time for make and give reproducable case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants