diff --git a/src/Classification.php b/src/Classification.php index 472caf7..c191e06 100644 --- a/src/Classification.php +++ b/src/Classification.php @@ -30,8 +30,9 @@ function classify($module_id, $sample_list, $sandbox=false, } else { $data = array('text_list' => $batch); } - + try{ list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} $headers[] = $header; $res = array_merge($res, $response['result']); } @@ -41,13 +42,17 @@ function classify($module_id, $sample_list, $sandbox=false, function list_classifiers($sleep_if_throttled=true) { $url = $this->endpoint; - list($response, $header) = $this->make_request($url, 'GET', null, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'GET', null, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } function detail($module_id, $sleep_if_throttled=true) { $url = $this->endpoint.$module_id; - list($response, $header) = $this->make_request($url, 'GET', null, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'GET', null, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } @@ -81,26 +86,33 @@ function upload_samples($module_id, $samples_with_categories, $sleep_if_throttle if ($features_schema) { $data['features_schema'] = $features_schema; } - - list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); + try { + list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } function train($module_id, $sleep_if_throttled=true) { $url = $this->endpoint.$module_id.'/train/'; - list($response, $header) = $this->make_request($url, 'POST', null, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'POST', null, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } function deploy($module_id, $sleep_if_throttled=true) { $url = $this->endpoint.$module_id.'/deploy/'; - list($response, $header) = $this->make_request($url, 'POST', null, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'POST', null, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } function delete($module_id, $sleep_if_throttled=true) { $url = $this->endpoint.$module_id; - list($response, $header) = $this->make_request($url, 'DELETE', null, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'DELETE', null, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } @@ -137,7 +149,9 @@ function create($name, $description=null, $train_state=null, $language=null, $ng } $url = $this->endpoint; - list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } } @@ -150,7 +164,9 @@ function __construct($token, $base_endpoint) { function detail($module_id, $category_id, $sleep_if_throttled=true) { $url = $this->endpoint.$module_id.'/categories/'.$category_id.'/'; - list($response, $header) = $this->make_request($url, 'GET', null, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'GET', null, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } @@ -162,7 +178,9 @@ function create($module_id, $name, $parent_id, $sleep_if_throttled=true) { ); $url = $this->endpoint.$module_id.'/categories/'; - list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } @@ -181,7 +199,9 @@ function edit($module_id, $category_id, $name=null, $parent_id=null, } $url = $this->endpoint.$module_id.'/categories/'.$category_id.'/'; - list($response, $header) = $this->make_request($url, 'PATCH', $data, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'PATCH', $data, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } @@ -200,7 +220,9 @@ function delete($module_id, $category_id, $samples_strategy=null, } $url = $this->endpoint.$module_id.'/categories/'.$category_id.'/'; - list($response, $header) = $this->make_request($url, 'DELETE', $data, $sleep_if_throttled); + try{ + list($response, $header) = $this->make_request($url, 'DELETE', $data, $sleep_if_throttled); + } catch (\MonkeyLearnException $mle){ throw $mle;} return new MonkeyLearnResponse($response['result'], array($header)); } }