Show micropub error descriptions v0.1.0
authorChristian Weiske <cweiske@cweiske.de>
Tue, 30 May 2017 21:39:25 +0000 (23:39 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 30 May 2017 21:39:25 +0000 (23:39 +0200)
init.php

index 745d432424a246172747c2af63687408f268b4b1..d561aa5421b561d2fe81269786625afdfb2bcf24 100644 (file)
--- a/init.php
+++ b/init.php
@@ -272,9 +272,18 @@ class Micropub extends Plugin implements IHandler
         $status = array_shift($headers);
         list($httpver, $code, $text) = explode(' ', $status, 3);
         if ($code != 201 && $code != 202) {
+            $errData = json_decode($content);
+            if (isset($errData->error_description)
+                && $errData->error_description != ''
+            ) {
+                return $this->errorOut(
+                    'Error creating post: '
+                    . $errData->error_description
+                );
+            }
             return $this->errorOut(
-                'An error occured: '
-                . $code . ' ' . $text
+                'Error creating post: '
+                . $code . ' ' . $text.$content
             );
         }