Project

General

Profile

Actions

Task #72254

closed

Throw sql exceptions with sql error number

Added by Carsten Bleicker almost 9 years ago. Updated almost 9 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-12-15
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Sprint Focus:

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.

Actions

Also available in: Atom PDF