Share
Talk Programming , Career, Mental Health, Talk Personal Finance ❤️???? Post a query and receive responses ✅
Post a query and receive responses. Ask anything, ASK ITSNP ❤️????
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a function which fetches json object from given url
it take two params
url
&error
, bydefault error param issomething went wrong
it means while calling the function you have to pass values in respective parametersIn this way
getJson(url="https://askmitra.com/", error="kei error pass garni else default error jancha")
if the response of the request to that url is NOT ok which is code 400 usually
then it throws the same error which was passed in parameters while calling the function as well as error code which was returned inresponse
whilefetching/ requesting
url in this way something went wrong response_statusreturn the json
it’s a method to throw an Exception if there occur.
Basically the exception is An event that occurs during the execution of a program that disrupts the normal flow of instructions is called an exception.
so the throw keyword will throw an exception if there occur like there is a function that takes two parameters url and error and if there will be any exception occur when running the function that will throw exception.
Thank you for your answers. That was helpful ❤️