File tree Expand file tree Collapse file tree 2 files changed +58
-2
lines changed Expand file tree Collapse file tree 2 files changed +58
-2
lines changed Original file line number Diff line number Diff line change 44
55use dokuwiki \HTTP \DokuHTTPClient ;
66use OAuth \Common \Http \Client \ClientInterface ;
7- use OAuth \Common \Http \Exception \TokenResponseException ;
87use OAuth \Common \Http \Uri \UriInterface ;
98
109/**
@@ -26,7 +25,11 @@ public function retrieveResponse(
2625 $ ok = $ http ->sendRequest ($ endpoint ->getAbsoluteUri (), $ requestBody , $ method );
2726 if (!$ ok || $ http ->status < 200 || $ http ->status > 299 ) {
2827 $ msg = "An error occured during the request to the oauth provider: \n" ;
29- throw new TokenResponseException ($ msg . $ http ->error . ' [HTTP ' . $ http ->status . '] ' );
28+ throw new HttpTokenResponseException (
29+ $ msg . $ http ->error . ' [HTTP ' . $ http ->status . '] ' ,
30+ $ http ->status ,
31+ $ http ->error
32+ );
3033 }
3134
3235 return $ http ->resp_body ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace dokuwiki \plugin \oauth ;
4+
5+ use OAuth \Common \Http \Exception \TokenResponseException ;
6+
7+ /**
8+ * Exception relating to http token response from service.
9+ */
10+ class HttpTokenResponseException extends TokenResponseException
11+ {
12+ protected $ httpStatusCode = 0 ;
13+ protected $ httpErrorMessage = "" ;
14+
15+ /**
16+ * @param string $message
17+ * @param int $httpStatusCode
18+ * @param string httpErrorMessage
19+ * @param int $code
20+ * @param \Throwable|null $previous
21+ */
22+ public function __construct (
23+ $ message = "" ,
24+ $ httpStatusCode = 0 ,
25+ $ httpErrorMessage = "" ,
26+ $ code = 0 ,
27+ \Throwable $ previous = null
28+ ) {
29+ parent ::__construct ($ message , $ code , $ previous );
30+ $ this ->httpStatusCode = $ httpStatusCode ;
31+ $ this ->httpErrorMessage = $ httpErrorMessage ;
32+ }
33+
34+ /**
35+ * Get the HTTP status code
36+ *
37+ * @return int
38+ */
39+ public function getHttpStatusCode ()
40+ {
41+ return $ this ->httpStatusCode ;
42+ }
43+
44+ /**
45+ * Get the HTTP error message
46+ *
47+ * @return string
48+ */
49+ public function getHttpErrorMessage ()
50+ {
51+ return $ this ->httpErrorMessage ;
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments