#72254Throw sql exceptions with sql error number
Description
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php:862
Current:
throw new \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException($error, 1247602160);
Better:
throw new \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException($error, 1247602160, $this->databaseHandle->sql_errno());
Passing the sql_errno() to exception is usefull f.e. for API Endpoints having unique constraints.
Currently its not possible to handline Duplicate Key db errors.
With sql_errno() you could do:
try{
// Create Record ...
}catch(SqlErrorException $e){
if($e->getSqlErrorNumber() === 1062){
throw new ThrowableException('Duplicate Entry ...', ....);
}
}
Also errno never appears in log entries of catched exceptions.