diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index 427be0ee34e6f0e388681f1a5888ebf0fe0f1083..397842db4156e840d8a76db2f9298d6d2cb46a5c 100644
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -366,13 +366,17 @@ class LDAP
    * \param integer $srp srp
    *
    */
-  function parse_result ($srp, &$errcode, &$matcheddn, &$errmsg, &$referrals, &$controls): bool
+  function parse_result ($srp): array
   {
     if ($this->hascon && $this->hasres[$srp]) {
-      return @ldap_parse_result($this->cid, $this->sr[$srp], $errcode, $matcheddn, $errmsg, $referrals, $controls);
+      if (ldap_parse_result($this->cid, $this->sr[$srp], $errcode, $matcheddn, $errmsg, $referrals, $controls)) {
+        return [$errcode, $matcheddn, $errmsg, $referrals, $controls];
+      } else {
+        throw new FusionDirectoryException(_('Parsing LDAP result failed'));
+      }
+    } else {
+      throw new FusionDirectoryException(_('No LDAP result to parse'));
     }
-
-    return FALSE;
   }
 
   /*
diff --git a/setup/class_setupStepMigrate.inc b/setup/class_setupStepMigrate.inc
index c54ea9d6f067c72e856ac438cea01917c1643315..dc71532be62eb0bfed6cbca001f72866bfb7402b 100644
--- a/setup/class_setupStepMigrate.inc
+++ b/setup/class_setupStepMigrate.inc
@@ -1011,10 +1011,12 @@ class setupStepMigrate extends setupStep
             _('Possibly the "root object" is missing.')
           );
         }
-        if (!$ldap->parse_result($errcode, $matcheddn, $errmsg, $referrals, $controls)) {
+        try {
+          list($errcode, $matcheddn, $errmsg, $referrals, $controls) = $ldap->parse_result();
+        } catch (FusionDirectoryException $e) {
           throw new CheckFailedException(
             _('LDAP result parsing failed'),
-            _('LDAP result parsing failed')
+            $e->getMessage()
           );
         }
         if ($errcode !== 0) {