@@ -1063,7 +1063,9 @@ public function rawJsonToArray($rawJson) {
10631063 $ responseDecoded = $ this ->nativeTypes ? $ this ->fixResponseTypes ($ responseDecoded [$ this ->nameSpace ]) : $ responseDecoded [$ this ->nameSpace ];
10641064 }
10651065 } else {
1066- if ($ this ->debug ) {
1066+ if ($ this ->throwException == true ) {
1067+ throw new Exception ('JSON Decoder: ' . $ decodeError , $ this );
1068+ } else {
10671069 $ this ->addStatusMessage ('JSON Decoder: ' . $ decodeError , 'error ' );
10681070 $ this ->addStatusMessage ($ rawJson , 'debug ' );
10691071 }
@@ -1140,10 +1142,9 @@ public function parseResponse($responseDecoded, $responseCode) {
11401142 }
11411143 case 401 :
11421144 $ msg = (array_key_exists ('message ' , $ responseDecoded ) ? $ responseDecoded ['message ' ] : $ responseDecoded [key ($ responseDecoded )]['message ' ]) . ' for ' . $ this ->getApiURL ();
1145+ $ this ->addStatusMessage ($ msg , 'error ' );
11431146 if ($ this ->throwException ) {
1144- throw new Exception ($ msg );
1145- } else {
1146- $ this ->addStatusMessage ($ msg , 'error ' );
1147+ throw new Exception ($ msg , $ this );
11471148 }
11481149 break ;
11491150 case 404 : // Page not found
@@ -1156,6 +1157,9 @@ public function parseResponse($responseDecoded, $responseCode) {
11561157 $ this ->parseError ($ responseDecoded );
11571158 }
11581159 $ this ->addStatusMessage ($ this ->lastResponseCode . ': ' . $ this ->curlInfo ['url ' ] . ' ( ' . $ this ->format . ') ' . json_encode ($ this ->getErrors ()), 'warning ' );
1160+ if ($ this ->throwException ) {
1161+ throw new Exception ('Problem ' , $ this );
1162+ }
11591163 break ;
11601164 }
11611165 return $ mainResult ;
@@ -1221,8 +1225,11 @@ public function doCurlRequest($url, $method, $format = null) {
12211225 $ this ->lastResponseCode = $ this ->curlInfo ['http_code ' ];
12221226 $ this ->lastCurlError = curl_error ($ this ->curl );
12231227 if (strlen ($ this ->lastCurlError )) {
1224- $ this ->addStatusMessage (sprintf ('Curl Error (HTTP %d): %s ' ,
1225- $ this ->lastResponseCode , $ this ->lastCurlError ), 'error ' );
1228+ $ msg = sprintf ('Curl Error (HTTP %d): %s ' , $ this ->lastResponseCode , $ this ->lastCurlError );
1229+ $ this ->addStatusMessage ($ msg , 'error ' );
1230+ if ($ this ->throwException ) {
1231+ throw new Exception ($ msg , $ this );
1232+ }
12261233 }
12271234
12281235 if ($ this ->debug === true ) {
@@ -2398,18 +2405,19 @@ public function getAbraFlexiURL() {
23982405 public function setMyKey ($ myKeyValue ) {
23992406 if (is_string ($ myKeyValue ) && substr ($ myKeyValue , 0 , 4 ) == 'ext: ' ) {
24002407 if (empty ($ this ->evidenceInfo ) || ($ this ->evidenceInfo ['extIdSupported ' ] == 'false ' )) {
2401- $ this ->addStatusMessage (sprintf (_ ('Evidence %s does not support extIDs ' ),
2402- $ this ->getEvidence ()), 'warning ' );
2408+ $ msg = sprintf (_ ('Evidence %s does not support extIDs ' ), $ this ->getEvidence ());
2409+ $ this ->addStatusMessage ($ msg , 'warning ' );
2410+ if ($ this ->throwException ) {
2411+ throw new Exception ($ msg , $ this );
2412+ }
24032413 $ res = false ;
24042414 } else {
24052415 $ extIds = $ this ->getDataValue ('external-ids ' );
24062416 if (!empty ($ extIds ) && count ($ extIds )) {
24072417 $ extIds = array_combine ($ extIds , $ extIds );
24082418 }
2409-
24102419 $ extIds [$ myKeyValue ] = $ myKeyValue ;
2411- $ res = $ this ->setDataValue ('external-ids ' ,
2412- $ extIds );
2420+ $ res = $ this ->setDataValue ('external-ids ' , $ extIds );
24132421 }
24142422 } else {
24152423 $ res = $ this ->setDataValue ($ this ->getKeyColumn (), $ myKeyValue );
@@ -2786,25 +2794,6 @@ public function getErrors() {
27862794 return $ this ->errors ;
27872795 }
27882796
2789- /**
2790- * Add message to stack to show or write to file
2791- * Přidá zprávu do zásobníku pro zobrazení uživateli inbo do logu.
2792- *
2793- * @param string $message text zpravy
2794- * @param string $type fronta
2795- * @param string $caller Message source name
2796- *
2797- * @return boolean message added
2798- */
2799- public function addStatusMessage ($ message , $ type = 'info ' , $ caller = null ) {
2800- $ callerFinal = empty ($ caller ) ? $ this : $ caller ;
2801- if (($ this ->throwException === true ) && (($ type == 'warning ' ) || ($ type == 'error ' ) )) {
2802- throw new Exception ($ type . ': ' . $ message . "\n" . 'caller: ' . (is_object ($ callerFinal ) ? get_class ($ callerFinal ) : $ callerFinal ));
2803- } else {
2804- parent ::addStatusMessage ($ message , $ type , $ callerFinal );
2805- }
2806- }
2807-
28082797 /**
28092798 * Reconnect After unserialization
28102799 */
0 commit comments