@@ -70,7 +70,7 @@ public function createOrganization(string $orgName): string
7070 $ responseHeaders = $ response ['headers ' ] ?? [];
7171 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
7272 if ($ statusCode >= 400 ) {
73- throw new Exception ("Creating organization {$ orgName } failed with status code {$ statusCode }" );
73+ throw new Exception ("Creating organization {$ orgName } failed with status code {$ statusCode }" , $ statusCode );
7474 }
7575
7676 return ($ responseBody ['id ' ] ?? '' ) . ': ' . ($ responseBody ['path ' ] ?? '' );
@@ -116,7 +116,7 @@ public function createRepository(string $owner, string $repositoryName, bool $pr
116116 $ responseHeaders = $ response ['headers ' ] ?? [];
117117 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
118118 if ($ statusCode >= 400 ) {
119- throw new Exception ("Creating repository {$ repositoryName } failed with status code {$ statusCode }" );
119+ throw new Exception ("Creating repository {$ repositoryName } failed with status code {$ statusCode }" , $ statusCode );
120120 }
121121 $ result = is_array ($ body ) ? $ body : [];
122122 $ result ['pushed_at ' ] = $ result ['last_activity_at ' ] ?? '' ;
@@ -134,7 +134,7 @@ public function deleteRepository(string $owner, string $repositoryName): bool
134134 $ responseHeaders = $ response ['headers ' ] ?? [];
135135 $ responseHeadersStatusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
136136 if ($ responseHeadersStatusCode >= 400 ) {
137- throw new Exception ("Deleting repository {$ repositoryName } failed with status code {$ responseHeadersStatusCode }" );
137+ throw new Exception ("Deleting repository {$ repositoryName } failed with status code {$ responseHeadersStatusCode }" , $ responseHeadersStatusCode );
138138 }
139139
140140 return true ;
@@ -393,7 +393,7 @@ public function createFile(string $owner, string $repositoryName, string $filepa
393393 $ responseHeaders = $ response ['headers ' ] ?? [];
394394 $ responseHeadersStatusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
395395 if ($ responseHeadersStatusCode >= 400 ) {
396- throw new Exception ("Failed to create file {$ filepath }: HTTP {$ responseHeadersStatusCode }" );
396+ throw new Exception ("Failed to create file {$ filepath }: HTTP {$ responseHeadersStatusCode }" , $ responseHeadersStatusCode );
397397 }
398398
399399 return $ response ['body ' ] ?? [];
@@ -413,7 +413,7 @@ public function createBranch(string $owner, string $repositoryName, string $newB
413413 $ responseHeaders = $ response ['headers ' ] ?? [];
414414 $ responseHeadersStatusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
415415 if ($ responseHeadersStatusCode >= 400 ) {
416- throw new Exception ("Failed to create branch {$ newBranchName }: HTTP {$ responseHeadersStatusCode }" );
416+ throw new Exception ("Failed to create branch {$ newBranchName }: HTTP {$ responseHeadersStatusCode }" , $ responseHeadersStatusCode );
417417 }
418418
419419 return $ response ['body ' ] ?? [];
@@ -437,7 +437,7 @@ public function createPullRequest(string $owner, string $repositoryName, string
437437 $ responseHeaders = $ response ['headers ' ] ?? [];
438438 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
439439 if ($ statusCode >= 400 ) {
440- throw new Exception ("Failed to create merge request: HTTP {$ statusCode }" );
440+ throw new Exception ("Failed to create merge request: HTTP {$ statusCode }" , $ statusCode );
441441 }
442442
443443 return $ response ['body ' ] ?? [];
@@ -463,7 +463,7 @@ public function createWebhook(string $owner, string $repositoryName, string $url
463463 $ responseHeadersStatusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
464464 if ($ responseHeadersStatusCode >= 400 ) {
465465 $ body = $ response ['body ' ] ?? [];
466- throw new Exception ("Failed to create webhook: HTTP {$ responseHeadersStatusCode } - " . json_encode ($ body ));
466+ throw new Exception ("Failed to create webhook: HTTP {$ responseHeadersStatusCode } - " . json_encode ($ body ), $ responseHeadersStatusCode );
467467 }
468468
469469 $ responseBody = $ response ['body ' ] ?? [];
@@ -481,7 +481,7 @@ public function createComment(string $owner, string $repositoryName, int $pullRe
481481 $ responseHeaders = $ response ['headers ' ] ?? [];
482482 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
483483 if ($ statusCode >= 400 ) {
484- throw new Exception ("Failed to create comment: HTTP {$ statusCode }" );
484+ throw new Exception ("Failed to create comment: HTTP {$ statusCode }" , $ statusCode );
485485 }
486486
487487 $ responseBody = $ response ['body ' ] ?? [];
@@ -525,7 +525,7 @@ public function updateComment(string $owner, string $repositoryName, string $com
525525
526526 $ responseHeaders = $ response ['headers ' ] ?? [];
527527 if (($ responseHeaders ['status-code ' ] ?? 0 ) !== 200 ) {
528- throw new Exception ("Failed to update comment: HTTP " . ($ responseHeaders ['status-code ' ] ?? 0 ));
528+ throw new Exception ("Failed to update comment: HTTP " . ($ responseHeaders ['status-code ' ] ?? 0 ), $ responseHeaders [ ' status-code ' ] ?? 0 );
529529 }
530530
531531 return $ commentId ;
@@ -540,7 +540,7 @@ public function getUser(string $username): array
540540 $ responseHeaders = $ response ['headers ' ] ?? [];
541541 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
542542 if ($ statusCode >= 400 ) {
543- throw new Exception ("Failed to get user: HTTP {$ statusCode }" );
543+ throw new Exception ("Failed to get user: HTTP {$ statusCode }" , $ statusCode );
544544 }
545545
546546 $ body = $ response ['body ' ] ?? [];
@@ -561,7 +561,7 @@ public function getOwnerName(string $installationId, ?int $repositoryId = null):
561561 $ responseHeaders = $ response ['headers ' ] ?? [];
562562 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
563563 if ($ statusCode >= 400 ) {
564- throw new Exception ("Failed to get owner name for repository {$ repositoryId }: HTTP {$ statusCode }" );
564+ throw new Exception ("Failed to get owner name for repository {$ repositoryId }: HTTP {$ statusCode }" , $ statusCode );
565565 }
566566 $ responseBody = $ response ['body ' ] ?? [];
567567 $ namespace = $ responseBody ['namespace ' ] ?? [];
@@ -573,7 +573,7 @@ public function getOwnerName(string $installationId, ?int $repositoryId = null):
573573 $ responseHeaders = $ response ['headers ' ] ?? [];
574574 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
575575 if ($ statusCode >= 400 ) {
576- throw new Exception ("Failed to get current user: HTTP {$ statusCode }" );
576+ throw new Exception ("Failed to get current user: HTTP {$ statusCode }" , $ statusCode );
577577 }
578578 $ responseBody = $ response ['body ' ] ?? [];
579579 return $ responseBody ['username ' ] ?? '' ;
@@ -590,7 +590,7 @@ public function getPullRequest(string $owner, string $repositoryName, int $pullR
590590 $ responseHeaders = $ response ['headers ' ] ?? [];
591591 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
592592 if ($ statusCode >= 400 ) {
593- throw new Exception ("Failed to get merge request: HTTP {$ statusCode }" );
593+ throw new Exception ("Failed to get merge request: HTTP {$ statusCode }" , $ statusCode );
594594 }
595595
596596 $ mr = $ response ['body ' ] ?? [];
@@ -642,7 +642,7 @@ public function getPullRequestFiles(string $owner, string $repositoryName, int $
642642 $ responseHeaders = $ response ['headers ' ] ?? [];
643643 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
644644 if ($ statusCode >= 400 ) {
645- throw new Exception ("Failed to get merge request files: HTTP {$ statusCode }" );
645+ throw new Exception ("Failed to get merge request files: HTTP {$ statusCode }" , $ statusCode );
646646 }
647647
648648 $ files = $ response ['body ' ] ?? [];
@@ -676,7 +676,7 @@ public function getPullRequestFromBranch(string $owner, string $repositoryName,
676676 $ responseHeaders = $ response ['headers ' ] ?? [];
677677 $ statusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
678678 if ($ statusCode >= 400 ) {
679- throw new Exception ("Failed to list merge requests: HTTP {$ statusCode }" );
679+ throw new Exception ("Failed to list merge requests: HTTP {$ statusCode }" , $ statusCode );
680680 }
681681
682682 $ body = $ response ['body ' ] ?? [];
@@ -765,7 +765,7 @@ public function getLatestCommit(string $owner, string $repositoryName, string $b
765765 $ responseHeaders = $ response ['headers ' ] ?? [];
766766 $ responseHeadersStatusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
767767 if ($ responseHeadersStatusCode >= 400 ) {
768- throw new Exception ("Failed to get latest commit: HTTP {$ responseHeadersStatusCode }" );
768+ throw new Exception ("Failed to get latest commit: HTTP {$ responseHeadersStatusCode }" , $ responseHeadersStatusCode );
769769 }
770770
771771 $ responseBody = $ response ['body ' ] ?? [];
@@ -823,7 +823,7 @@ public function updateCommitStatus(string $repositoryName, string $commitHash, s
823823 $ responseHeaders = $ response ['headers ' ] ?? [];
824824 $ responseHeadersStatusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
825825 if ($ responseHeadersStatusCode >= 400 ) {
826- throw new Exception ("Failed to update commit status: HTTP {$ responseHeadersStatusCode }" );
826+ throw new Exception ("Failed to update commit status: HTTP {$ responseHeadersStatusCode }" , $ responseHeadersStatusCode );
827827 }
828828 }
829829
@@ -968,7 +968,7 @@ public function createTag(string $owner, string $repositoryName, string $tagName
968968 $ responseHeaders = $ response ['headers ' ] ?? [];
969969 $ responseHeadersStatusCode = $ responseHeaders ['status-code ' ] ?? 0 ;
970970 if ($ responseHeadersStatusCode >= 400 ) {
971- throw new Exception ("Failed to create tag {$ tagName }: HTTP {$ responseHeadersStatusCode }" );
971+ throw new Exception ("Failed to create tag {$ tagName }: HTTP {$ responseHeadersStatusCode }" , $ responseHeadersStatusCode );
972972 }
973973
974974 return $ response ['body ' ] ?? [];
0 commit comments