Skip to content

Commit 9a6b8bd

Browse files
committed
rename HTTPException to JIRAException
1 parent dae0ebb commit 9a6b8bd

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function getConfig() {
2020
'CURLOPT_SSL_VERIFYHOST' => false,
2121
'CURLOPT_SSL_VERIFYPEER' => false,
2222
'CURLOPT_VERBOSE' => true,
23-
'LOG_FILE' => 'QQjira-rest-client.log',
23+
'LOG_FILE' => 'jira-rest-client.log',
2424
'LOG_LEVEL' => 'DEBUG'
2525
);
2626
}
@@ -45,7 +45,7 @@ try {
4545
$p = $proj->get('TEST');
4646

4747
print_r($p);
48-
} catch (HTTPException $e) {
48+
} catch (JIRAException $e) {
4949
print("Error Occured! " . $e->getMessage());
5050
}
5151
?>
@@ -64,14 +64,13 @@ try {
6464

6565
$prjs = $proj->getAllProjects();
6666

67-
$i = 0;
6867
foreach ($prjs as $p) {
6968
echo sprintf("Project Key:%s, Id:%s, Name:%s, projectCategory: %s\n",
7069
$p->key, $p->id, $p->name, $p->projectCategory['name']
7170
);
7271

7372
}
74-
} catch (HTTPException $e) {
73+
} catch (JIRAException $e) {
7574
print("Error Occured! " . $e->getMessage());
7675
}
7776
?>
@@ -91,7 +90,7 @@ try {
9190
$issue = $issueService->get('TEST-867');
9291

9392
print_r($issue->fields);
94-
} catch (HTTPException $e) {
93+
} catch (JIRAException $e) {
9594
print("Error Occured! " . $e->getMessage());
9695
}
9796

@@ -109,7 +108,7 @@ use JiraRestApi\Issue\IssueService;
109108
use JiraRestApi\Issue\IssueField;
110109
try {
111110
$issueField = new IssueField();
112-
$issueField->setProjectId("12000")
111+
$issueField->setProjectKey("TEST")
113112
->setSummary("something's wrong")
114113
->setAssigneeName("lesstif")
115114
->setPriorityName("Critical")
@@ -124,7 +123,7 @@ try {
124123

125124
//If success, Returns a link to the created issue.
126125
print_r($ret);
127-
} catch (HTTPException $e) {
126+
} catch (JIRAException $e) {
128127
print("Error Occured! " . $e->getMessage());
129128
}
130129

src/JiraClient.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
require 'vendor/autoload.php';
66

7-
class HTTPException extends \Exception { }
7+
class JIRAException extends \Exception { }
88

99
use \Monolog\Logger as Logger;
1010
use \Monolog\Handler\StreamHandler;
@@ -134,7 +134,7 @@ public function exec($context, $post_data = null, $custom_request = null) {
134134
curl_close($ch);
135135
// HostNotFound, No route to Host, etc Network error
136136
$this->log->addError("CURL Error: = " . $body);
137-
throw new HTTPException("CURL Error: = " . $body);
137+
throw new JIRAException("CURL Error: = " . $body);
138138
} else {
139139
// if request was ok, parsing http response code.
140140
$this->http_response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@@ -143,9 +143,9 @@ public function exec($context, $post_data = null, $custom_request = null) {
143143

144144
// don't check 301, 302 because setting CURLOPT_FOLLOWLOCATION
145145
if ($this->http_response != 200 && $this->http_response != 201) {
146-
throw new HTTPException("CURL HTTP Request Failed: Status Code : "
147-
. $this->http_response . " URL:" . $url
148-
. "\nError Message : " . $response);
146+
throw new JIRAException("CURL HTTP Request Failed: Status Code : "
147+
. $this->http_response . ", URL:" . $url
148+
. "\nError Message : " . $response, $this->http_response);
149149
}
150150
}
151151

src/issue/IssueField.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ public function __construct() {
1313
$this->issuetype = new \JiraRestApi\Issue\IssueType();
1414
}
1515

16-
public function setProjectName($name) {
17-
$this->project->name = $name;
16+
public function getProjectKey() {
17+
return $this->project->key;
18+
}
19+
20+
public function getProjectId() {
21+
return $this->project->id;
22+
}
23+
24+
public function setProjectKey($key) {
25+
$this->project->key = $key;
1826
return $this;
1927
}
2028
public function setProjectId($id) {

src/issue/IssueService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct() {
1515
* @return Issue class
1616
*/
1717
public function get($issueIdOrKey) {
18-
$ret = $this->exec("$this->uri/$issueIdOrKey", null);
18+
$ret = $this->exec($this->uri . "/$issueIdOrKey", null);
1919

2020
$this->log->addInfo("Result=\n" . $ret );
2121

@@ -41,6 +41,7 @@ public function create($issueField) {
4141
return !is_null($val);
4242
});
4343

44+
4445
$data = json_encode($issue);
4546

4647
$this->log->addInfo("Create Issue=\n" . $data );

tests/IssueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testCreateIssue()
3232
try {
3333
$issueField = new IssueField();
3434

35-
$issueField->setProjectId("12000")
35+
$issueField->setProjectKey("TEST")
3636
->setSummary("something's wrong")
3737
->setAssigneeName("lesstif")
3838
->setPriorityName("Critical")
@@ -47,7 +47,7 @@ public function testCreateIssue()
4747

4848
//If success, Returns a link to the created issue.
4949
print_r($ret);
50-
} catch (HTTPException $e) {
50+
} catch (JIRAException $e) {
5151
$this->assertTrue(FALSE, "Create Failed : " . $e->getMessage());
5252
}
5353
}

0 commit comments

Comments
 (0)