Meaningful error messages
andreElrico opened this issue · 2 comments
When ANYTHING goes wrong in the lazy module when "attaching" the module, I get the same error message:
ERROR Error: Uncaught (in promise): Error created and attaching module async.
For example I forgot to provide Service1
that is injected in a component and therefore get the "injector cant resolve ..." error. This error is also reflected as: ERROR Error: Uncaught (in promise): Error created and attaching module async.
which makes it hard to debug.
The obvious workaround is to develop the module EGERLY and then lazyload the finished product.
Is there any other solution ?
Workaround im currently using:
- comment out
bootstrap
argument in LAZY_MODULE decorator - add LAZY_MODULE in app.module (root module)
- add code somewhere in
app.component.html
<button style="position: absolute;" #b1 value="1" (click)="b1.value = b1.value == 1 ? 0 : 1;">RELOADER BTN</button>
<div *ngIf="b1.value == 1" style="position: absolute; background-color: #FFCCDA; top: 7em; right: 0; left: 0; bottom: 0;">
<app-MyBootstrapComponent></app-MyBootstrapComponent>
</div>
- Develop till perfect.
- Revert step 1 + 2,
- Comment out code of 3. You might need it for the next lazyModule.
please throw the error in the catch
catch (e) {
rej('Error created and attaching module async.');
throw e
}
probably also here:
and here
otherwise we only get 'ERROR Error: Uncaught (in promise): Error created and attaching module async.'
as error message which is not helpful for debugging.
Current Workaround:
- search for "Error created and attaching module async." in Dev-Tools
- add a debugger-break point before
rej
- produce the error again
- type the error-argument into console to get a clue what caused the error.