Removing all console errors
Console Errors
Susi is a personal assistant developed by FOSSASIA. It has many clients including web chat, andoid and iOS app, and many chatbots.
Now we are developing a chrome extension for it which is named as chromebot.
There were many errors in console.
The errors were-
Uncaught TypeError: Cannot read property 'addEventListener` of null at allowmic.js :5
Failed to load resource: net:: ERR_FILE_NOT_FOUND
Following the stack trace of the first error I found out that two elements were present on login page and was only present in DOM when the login page gets opened.
And the allowmic.js was necessary to be included in the main extension window.
So for figuring out the solution I put all the event listeners in a if clause
if(micAccess) {
micAccess.addEventListener("click", () => {
navigator.webkitGetUserMedia({
audio: true
}, function (stream) {
stream.stop();
}, function () {
console.log("no access");
});
});
}
if(preDefThemes) {
preDefThemes.addEventListener("click",(e) => {
if(e.target!==e.currentTarget){
theme= e.target.id;
console.log(theme);
}
e.stopPropagation;
});
}
if(submit) {
submit.addEventListener("click",()=>{
localStorage.setItem("theme",theme);
console.log("success");
alert("success");
});
}
if(backgroundChange) {
backgroundChange.addEventListener("submit", (e) => {
e.preventDefault();
theValue = backUrl.value;
if (!theValue) {
alert("Error: No value specified");
} else {
localStorage.setItem("theValue", theValue);
alert("Successfully stored");
}
});
}
Which solved my first issue of errors due to Uncaught TypeError.
Second Error was due to there was a custom background variable which was used in setting custom background which was only set when user chose a custom background.
So I put it as optional.
Then the console was free of errors.
For Browsing the code of susi chromebot, Click here
Posted on Utopian.io - Rewarding Open Source Contributors
Leave Removing all console errors to:
Read more #utopian-io posts
Best Posts From Mohit Sharma
We have not curated any of ms10398's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Mohit Sharma
- My Actifit Report Card: January 1 2019
- My Actifit Report Card: December 31 2018
- My Actifit Report Card: December 30 2018
- My Actifit Report Card: December 29 2018
- Testing Translations
- This is a title
- Development of Utopian Reviews
- Memeit Development(Front End Changes)
- Major Improvements in Memeit.lol
- Documentation of Open Food Facts Node Wrapper using jsdoc