Skip to content

Commit

Permalink
add 404 error handle
Browse files Browse the repository at this point in the history
  • Loading branch information
leamare committed May 20, 2018
1 parent e8f0b59 commit f0e3f10
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions simple_opendota.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,19 @@ private function request($url, $mode, $data = [], $post = false) {
$result = json_decode($result, true);

if(isset($result['error']) || empty($result)) {
if ( $mode == 0 ) {
if ( $mode == -1 ) {
if ( $this->report_status )
echo("[E] OpenDotaPHP: ".$result['error'].". Skipping request\n");
return false;
} else if ( $result['error'] == "Not Found" ) {
if ( $this->report_status )
echo("[ ] OpenDotaPHP: 404, Skipping\n");
return false;
} if ( $mode == 0 ) {
if ( $this->report_status )
echo("[ ] OpenDotaPHP: ".$result['error'].". Waiting\n");
sleep(1);
return $this->request($url, $mode, $data, $post);
} else if ( $mode == -1 ) {
if ( $this->report_status )
echo("[E] OpenDotaPHP: ".$result['error'].". Skipping request\n");
return false;
}
} else {
return $result;
Expand Down

0 comments on commit f0e3f10

Please sign in to comment.