Skip to content
Snippets Groups Projects
Commit 9e056fde authored by Mark Winter's avatar Mark Winter
Browse files

Try to handle 404 errors (WIP)

REBASE: fix query

REBASE: response code fix

REBASE: response fix
parent 9e61bab1
Branches
No related tags found
No related merge requests found
......@@ -33,9 +33,11 @@ function resp = reddit_query(endpoint, tokenObj)
'Timeout',60,...
'HeaderFields',headers);
resp = struct('data',{[]});
try
resp = webread(url, opts);
catch me
if ( strcmp(me.identifier,'MATLAB:webservices:HTTP401StatusCodeError') )
getAuthToken(tokenObj);
headers = {'Authorization', sprintf('%s %s', tokenObj.TokenType, tokenObj.AccessToken)};
......@@ -43,6 +45,9 @@ function resp = reddit_query(endpoint, tokenObj)
'Timeout',60,...
'HeaderFields',headers);
resp = webread(url, opts);
else
rethrow(me);
end
end
% Manually reset rate-limits to avoid overloading since matlab doesn't
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment