herodevs/herodevs-packages

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:

  1. comment out bootstrap argument in LAZY_MODULE decorator
  2. add LAZY_MODULE in app.module (root module)
  3. 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>
  1. Develop till perfect.
  2. Revert step 1 + 2,
  3. Comment out code of 3. You might need it for the next lazyModule.

@aaronfrost

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:

  1. search for "Error created and attaching module async." in Dev-Tools
  2. add a debugger-break point before rej
  3. produce the error again
  4. type the error-argument into console to get a clue what caused the error.