mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Handle structure exception
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ class Create extends Action
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/transactions/:transactionId/operations')
|
||||
->desc('Add operations to transaction')
|
||||
->desc('Create operations scoped to a transaction')
|
||||
->groups(['api', 'database', 'transactions'])
|
||||
->label('scope', 'transactions.write')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
|
||||
@@ -17,7 +17,7 @@ use Utopia\Database\Exception\Authorization;
|
||||
use Utopia\Database\Exception\Conflict as ConflictException;
|
||||
use Utopia\Database\Exception\Duplicate as DuplicateException;
|
||||
use Utopia\Database\Exception\NotFound as NotFoundException;
|
||||
use Utopia\Database\Exception\Structure;
|
||||
use Utopia\Database\Exception\Structure as StructureException;
|
||||
use Utopia\Database\Exception\Transaction as TransactionException;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\UID;
|
||||
@@ -210,6 +210,11 @@ class Update extends Action
|
||||
'status' => 'failed',
|
||||
]));
|
||||
throw new Exception(Exception::TRANSACTION_CONFLICT, previous: $e);
|
||||
} catch (StructureException $e) {
|
||||
$dbForProject->updateDocument('transactions', $transactionId, new Document([
|
||||
'status' => 'failed',
|
||||
]));
|
||||
throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $e->getMessage());
|
||||
} catch (TransactionException $e) {
|
||||
$dbForProject->updateDocument('transactions', $transactionId, new Document([
|
||||
'status' => 'failed',
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class Create extends OperationsCreate
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/tablesdb/transactions/:transactionId/operations')
|
||||
->desc('Add operations to transaction')
|
||||
->desc('Create operations scoped to a transaction')
|
||||
->groups(['api', 'database', 'transactions'])
|
||||
->label('scope', 'transactions.write')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
|
||||
@@ -96,7 +96,7 @@ class TransactionsTest extends Scope
|
||||
/**
|
||||
* Test adding operations to a transaction
|
||||
*/
|
||||
public function testAddOperations(): void
|
||||
public function testCreateOperations(): void
|
||||
{
|
||||
// Create database first
|
||||
$database = $this->client->call(Client::METHOD_POST, '/databases', array_merge([
|
||||
|
||||
@@ -96,7 +96,7 @@ class TransactionsTest extends Scope
|
||||
/**
|
||||
* Test adding operations to a transaction
|
||||
*/
|
||||
public function testAddOperations(): void
|
||||
public function testCreateOperations(): void
|
||||
{
|
||||
// Create database first
|
||||
$database = $this->client->call(Client::METHOD_POST, '/tablesdb', array_merge([
|
||||
|
||||
Reference in New Issue
Block a user