N°8772 - OQL exceptions

This commit is contained in:
Eric Espie
2025-11-26 09:34:21 +01:00
parent 8e3d132714
commit 852238a110
2 changed files with 10 additions and 4 deletions

View File

@@ -72,9 +72,15 @@ class OQLException extends CoreException
}
else
{
$sExpectations = '{'.implode(', ', $this->m_aExpecting).'}';
$sMessage = "$sIssue - found '{$this->m_sUnexpected}' at $iCol in '$sInput'";
if (count($this->m_aExpecting) < 30) {
$sExpectations = '{'.implode(', ', $this->m_aExpecting).'}';
$sMessage .= ', expecting '.json_encode($sExpectations);
}
$sSuggest = self::FindClosestString($this->m_sUnexpected, $this->m_aExpecting);
$sMessage = "$sIssue - found '{$this->m_sUnexpected}' at $iCol in '$sInput', expecting $sExpectations, I would suggest to use '$sSuggest'";
if (strlen($sSuggest) > 0) {
$sMessage .= ", I would suggest to use ".json_encode($sSuggest);
}
}
// make sure everything is assigned properly
@@ -155,5 +161,3 @@ class OQLException extends CoreException
return $sRet;
}
}
?>

View File

@@ -33,6 +33,8 @@ class OqlToClassConverter extends AbstractConverter
$oModelReflection = DIService::GetInstance()->GetService('ModelReflection');
try {
$oQuery = $oModelReflection->GetQuery($oData);
} catch (\OQLParserException $e) {
throw new FormBlockIOException($e->GetIssue(), $e->getCode(), $e);
} catch (Exception $e) {
throw new FormBlockIOException($e->getMessage(), $e->getCode(), $e);
}