[icinga-checkins] icinga.org: icingaweb2-module-director/master: DirectorObjectForm: improve Exception error message

git at icinga.org git at icinga.org
Wed Oct 5 22:13:57 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 70b8a9ea023b55f969045dd36cc895589f40a3d9
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=70b8a9ea023b55f969045dd36cc895589f40a3d9

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Oct  5 18:03:07 2016 +0000

DirectorObjectForm: improve Exception error message

---

 library/Director/Web/Form/DirectorObjectForm.php |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php
index 287159d..3b98340 100644
--- a/library/Director/Web/Form/DirectorObjectForm.php
+++ b/library/Director/Web/Form/DirectorObjectForm.php
@@ -214,7 +214,22 @@ abstract class DirectorObjectForm extends QuickForm
                     }
 
                 } catch (Exception $e) {
-                    $this->getElement($key)->addError($e->getMessage());
+
+                    $file = preg_split('/[\/\\\]/', $e->getFile(), -1, PREG_SPLIT_NO_EMPTY);
+                    $file = array_pop($file);
+                    $msg = sprintf(
+                        '%s (%s:%d)',
+                        $e->getMessage(),
+                        $file,
+                        $e->getLine()
+                    );
+
+                    if ($el = $this->getElement($key)) {
+                        // TODO: to be preferred $el->addError($e->getMessage());
+                        $this->addError($msg);
+                    } else {
+                        $this->addError($msg);
+                    }
                 }
             }
         }



More information about the icinga-checkins mailing list