question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error is undefinied from OnError($event)

See original GitHub issue
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [x] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request

Hello, I don’t know if this behavior is normal but I’m having trouble getting details of an (intentional) error here is my PDF viewer in HTML

<pdf-viewer 
  [src]="PDF" 
  [render-text]="true"
  style="display: block;"
  (on-progress)="onProgress($event)"
  (after-load-complete)='PDF_loaded()'
  (error)="onError($event)">
</pdf-viewer>

and here is the onError function in the .TS

onError(errorPDF: any){console.log(errorPDF)}

the url of the pdf request returns a 404 error (as intended in my EXPRESS api )

res.status(404).send({ error: 'Not Found' });

In the chrome console i only get an ‘undefined’ for the ‘console.log (error PDF)’ Is it normal? Is there a way to get the code error thanks to the ‘OnError’ function?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
stephanrauhcommented, Dec 29, 2020

Found it. The error message is a victim of minification. If you’re using the non-minified version of the pdf.worker.js, the error object has a sensible value. In my case, I’ve added this line to the app.module.ts:

(window as any).pdfWorkerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.5.207/build/pdf.worker.js';
1reaction
harivenkatesh-idcommented, Feb 9, 2021

Found it. The error message is a victim of minification. If you’re using the non-minified version of the pdf.worker.js, the error object has a sensible value. In my case, I’ve added this line to the app.module.ts:

(window as any).pdfWorkerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.5.207/build/pdf.worker.js';

Thanks @stephanrauh this fixes the issue. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript: Which parameters are there for the onerror event ...
which I got from: javascript: how to display script errors in a popup alert? returns Error: [object Event] Script: undefined Line: undefined ......
Read more >
event error handler javascript Undefined. - Telerik Forums
I am trying to use the events(e => e.Error("onError") in my grid that is ajax bound. I keep getting a javascript error "onError"...
Read more >
Window: error event - Web APIs - MDN Web Docs - Mozilla
The error event is fired on a Window object when a resource failed to load or couldn't be used — for example if...
Read more >
onerror Event - W3Schools
The onerror event is triggered if an error occurs while loading an external file (e.g. a document or an image). Tip: When used...
Read more >
this._listeners.error is undefined · Issue #63 - GitHub
I'm running into the following scenario, I'm providing incorrect URL on perpouse with 0 retry option. const options = { connectionTimeout: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found