-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
console-err-msg #430
console-err-msg #430
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/saadpasta/developer-folio/Sis1cT2Xy6miZfydqQGGSvVqrAyv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a quick look over the changes and it seems you understood the issues incorrectly. The issue #212 says to add error messages for only third party components, i.e GitHub repos, Twitter embed, podcasts and the GitHub contact components.
Throwing errors for missing fields would be counter intuitive as we also want users to have the option to keep fields blank if they wish to do so. Lots of errors in the console blowing up in people's face will make them feel they're doing something wrong when it's just an empty field.
Also looking at the implementation, you're using logs instead of errors which isn't the best way to warn someone.
@@ -16,6 +20,9 @@ export default function EducationCard({school}) { | |||
: null; | |||
}; | |||
const {isDark} = useContext(StyleContext); | |||
|
|||
if (!school.logo) | |||
console.log(`Image of schoolName ${school.name} is not available`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can keep this in as it seems helpful but change it to console.error('Image of ${school.name} is missing in education section');
src/components/errorfunc.js
Outdated
@@ -0,0 +1,48 @@ | |||
//function to check whether the url is correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll probably need to scrap all of this code and it's usage in other components as it isn't what is required currently :(
okay, so you want the error using throw error instead of log. right will do this one |
I have converted the console messages in third party components to error messages and removed them from the rest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of changes to make so please see all review comments and double check to not leave any changes not relevant to the PR.
Also, run prettier and fix all the code formatting inconsistencies.
src/components/blogCard/BlogCard.js
Outdated
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this extra line
src/components/blogCard/BlogCard.js
Outdated
var win = window.open(url, "_blank"); | ||
win.focus(); | ||
} | ||
|
||
return ( | ||
<div onClick={() => openUrlInNewTab(blog.url)}> | ||
<div onClick={() => openUrlInNewTab(blog.url, blog.img, blog.title)}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would work incorrectly to log image path so we don't need to pass blog.img
here.
)) | ||
: null; | ||
if (!descBullets) return null; | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need an if-else statement here since it will be evaluated to null by the ternary operator if it's false. Adding this would be an unnecessary extra step so let's revert this.
@@ -7,6 +7,7 @@ export default function EducationCard({school}) { | |||
const imgRef = createRef(); | |||
|
|||
const GetDescBullets = ({descBullets}) => { | |||
if (!descBullets) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as ExperienceCard.js
, let's revert this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed reverting these changes.
if (!url) { | ||
console.log(`URl for ${name} not found `); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space at the end of the string and use 'URL'
src/containers/podcast/Podcast.js
Outdated
@@ -6,6 +6,10 @@ import StyleContext from "../../contexts/StyleContext"; | |||
|
|||
export default function Podcast() { | |||
const {isDark} = useContext(StyleContext); | |||
|
|||
if (!podcastSection) | |||
throw new Error("Podcast objects for Podcast section is missing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's stick to throwing errors only in console throughout the app so use console.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will revert this but I wanted to discuss whether if throwing an error is a better choice than using the console. error since we are using map function and it is better to let the user know that the object is missing since we will get an error anyway if it is undefined and we using the map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We return just below this line (L13) if the object is undefined or display is set to false so it will be covered.
src/containers/profile/Profile.js
Outdated
@@ -21,7 +22,7 @@ export default function Profile() { | |||
if (result.ok) { | |||
return result.json(); | |||
} | |||
console.error(result); | |||
throw new Error("Couldn't fetch profile.json data"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need any error here since we're catching it below
src/containers/profile/Profile.js
Outdated
openSource.showGithubProfile = "false"; | ||
throw new Error( | ||
`${error} occured when tried to fetch profile data` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this and go back to using console.error
src/containers/projects/Projects.js
Outdated
@@ -50,6 +50,11 @@ export default function Projects() { | |||
<h1 className="project-title">Open Source Projects</h1> | |||
<div className="repo-cards-div-main"> | |||
{repo.map((v, i) => { | |||
if (!v) { | |||
throw new Error( | |||
`Github Object for repository number : ${i + 1} is undefined` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See object v
in GithubRepoCard
and use repository name instead of number in the error.
Also, use console.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I tried doing this but it complains you can not access the .node.id property when u pass props to the GithubRepocard so we have to display the error before we pass the props
Secondly, the name is present in the object v in the node key so I don't think there is any other way to get the name of the repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant display repo name using v.node.name
here instead of repo id if possible, since that would make the message more verbose.
@@ -24,6 +24,9 @@ export default function Twitter() { | |||
if (!twitterDetails.display) { | |||
return null; | |||
} | |||
if (!twitterDetails.userName) { | |||
throw new Error("Twitter details for twitter section are missing "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- use console.error
- change error to 'Twitter username for Twitter section is missing'
- Remove extra space at the end of string
sorry @kartikcho for being such a pain making you request changes again and again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're almost there and can get this in soon, just need to address a few more comments. Make sure to not leave any extra lines committed and run formatting just to be extra sure.
Also, don't feel bad if your PR is taking more rounds of reviews, we're all learning here!
@@ -7,6 +7,7 @@ export default function EducationCard({school}) { | |||
const imgRef = createRef(); | |||
|
|||
const GetDescBullets = ({descBullets}) => { | |||
if (!descBullets) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed reverting these changes.
@@ -18,6 +18,7 @@ export default function ExperienceCard({cardInfo, isDark}) { | |||
} | |||
|
|||
const GetDescBullets = ({descBullets, isDark}) => { | |||
if (!descBullets) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this too, remove this as we're checking for descBullets
using the ternary operator below.
@@ -6,11 +6,13 @@ import emoji from "react-easy-emoji"; | |||
import {Fade} from "react-reveal"; | |||
|
|||
export default function GithubProfileCard({prof}) { | |||
if (!prof) throw new Error("GithubProfileObject missing "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all changes from this file then @Rispectech
if (!url) { | ||
console.log(`Url in ${name} is undefined`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Overlooked this 'URL' :P
src/containers/profile/Profile.js
Outdated
@@ -7,6 +7,7 @@ const renderLoader = () => <Loading />; | |||
const GithubProfileCard = lazy(() => | |||
import("../../components/githubProfileCard/GithubProfileCard") | |||
); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra line committed
src/containers/profile/Profile.js
Outdated
openSource.showGithubProfile = "false"; | ||
console.error(`${error} occured when trying to fetch profile`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error that would be caught here would be a complete error message in itself so we don't need to wrap it in a message here as it would make the error log confusing.
src/containers/projects/Projects.js
Outdated
@@ -50,6 +50,11 @@ export default function Projects() { | |||
<h1 className="project-title">Open Source Projects</h1> | |||
<div className="repo-cards-div-main"> | |||
{repo.map((v, i) => { | |||
if (!v) { | |||
throw new Error( | |||
`Github Object for repository number : ${i + 1} is undefined` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant display repo name using v.node.name
here instead of repo id if possible, since that would make the message more verbose.
@@ -24,6 +24,9 @@ export default function Twitter() { | |||
if (!twitterDetails.display) { | |||
return null; | |||
} | |||
if (!twitterDetails.userName) { | |||
console.error("Twitter username for twitter section are missing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 'Twitter username for Twitter section is missing'
i don't mind getting reviews on my pr it just shows where I am lacking. it's just that constantly disturbing you is bugging me 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of small changes to address and also revert the GitHub repo error message to how it was before, using repo index.
Almost there!
@@ -11,6 +11,7 @@ export default function GithubProfileCard({prof}) { | |||
} else { | |||
prof.hireable = "No"; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this extra line
src/containers/podcast/Podcast.js
Outdated
@@ -6,6 +6,10 @@ import StyleContext from "../../contexts/StyleContext"; | |||
|
|||
export default function Podcast() { | |||
const {isDark} = useContext(StyleContext); | |||
|
|||
if (!podcastSection) | |||
console.error("Podcast objects for Podcast section is missing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this to 'podcastSection' object for Podcast section is missing
to make it a bit nicer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if I am understanding right, you want the variable podcastSection
which was in the if statement in the string right ? .
assuming so it won't work since this if block fires only when podcastSection
is null so if we pull it in the string
the output we get would be
"null / undefined objects for Podcast section is missing "
src/containers/podcast/Podcast.js
Outdated
@@ -26,6 +30,11 @@ export default function Podcast() { | |||
</div> | |||
<div className="podcast-main-div"> | |||
{podcastSection.podcast.map((podcastLink, i) => { | |||
if (!podcastLink) { | |||
console.log( | |||
`podcast link for ${podcastSection.title} is missing` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Use a capital P at the start of the sentence :P
src/containers/projects/Projects.js
Outdated
@@ -50,6 +50,9 @@ export default function Projects() { | |||
<h1 className="project-title">Open Source Projects</h1> | |||
<div className="repo-cards-div-main"> | |||
{repo.map((v, i) => { | |||
if (!v) { | |||
console.error(`Github Object for ${v.node.name} is undefined`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this should work but I'm just speculating without digging deep into it.
Revert it the previous error message you proposed using repo index for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I know that my solution was messy and not informative but I couldn't figure out how to access the name since v is undefined. i would like to better than this but cant figure out how to do so
I have done these changes and I wasn't so sure about the GitHub repo error so if are talking about the error messages in getRepoData in project.js in container, I have done that |
src/containers/podcast/Podcast.js
Outdated
@@ -6,6 +6,10 @@ import StyleContext from "../../contexts/StyleContext"; | |||
|
|||
export default function Podcast() { | |||
const {isDark} = useContext(StyleContext); | |||
|
|||
if (!podcastSection) | |||
console.error(`${podcastSection} object for Podcast section is missing`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being confusing before, I didn't mean to print the object in the console, just the variable name.
So it should look like console.error('podcastSection object for Podcast section is missing');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. i have done the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to go, thanks!
@allcontributors add @Rispectech for code |
I've put up a pull request to add @Rispectech! 🎉 |
* console-err-msg * fixed console to error message * requested changes * . * githubprofilecard-revert * required changes * changes-required * changes-required
In order to prevent redundancy in each component, I created a new js file (errorfunc.js) which contains all the error functions I used apart from occasional exceptions where it couldn't be used
in errorfunc.js , checkMissingValueObj checks whether the values are present or not