From 74b11f6c7b92b7834a097ab7bf96e2f6583bef96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Mon, 25 Jan 2016 14:47:37 +0100 Subject: [PATCH] Stop publishing on duplicate page --- libs/Format/Confluence/Api.php | 4 ++++ libs/Format/Confluence/DuplicateTitleException.php | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 libs/Format/Confluence/DuplicateTitleException.php diff --git a/libs/Format/Confluence/Api.php b/libs/Format/Confluence/Api.php index 79de0a6..403fa04 100644 --- a/libs/Format/Confluence/Api.php +++ b/libs/Format/Confluence/Api.php @@ -69,6 +69,10 @@ class Api $message .= (string) $response->getBody(); } + if ($level == '4' && strpos($message, "page with this title already exists") !== false) { + return new DuplicateTitleException($message, 0, $e->getPrevious()); + } + return new BadResponseException($message, $request, $response, $e->getPrevious()); } diff --git a/libs/Format/Confluence/DuplicateTitleException.php b/libs/Format/Confluence/DuplicateTitleException.php new file mode 100644 index 0000000..79cc7ee --- /dev/null +++ b/libs/Format/Confluence/DuplicateTitleException.php @@ -0,0 +1,6 @@ +