Skip to content

Commit ad2ae03

Browse files
Copilothotlong
andcommitted
fix: replace throw new Error with ObjectQLError in memory driver
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent d9d07b4 commit ad2ae03

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

packages/drivers/memory/src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ export class MemoryDriver implements Driver {
10851085
switch (command.type) {
10861086
case 'create':
10871087
if (!command.data) {
1088-
throw new Error('Create command requires data');
1088+
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Create command requires data' });
10891089
}
10901090
const created = await this.create(command.object, command.data, cmdOptions);
10911091
return {
@@ -1096,7 +1096,7 @@ export class MemoryDriver implements Driver {
10961096

10971097
case 'update':
10981098
if (!command.id || !command.data) {
1099-
throw new Error('Update command requires id and data');
1099+
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Update command requires id and data' });
11001100
}
11011101
const updated = await this.update(command.object, command.id, command.data, cmdOptions);
11021102
return {
@@ -1107,7 +1107,7 @@ export class MemoryDriver implements Driver {
11071107

11081108
case 'delete':
11091109
if (!command.id) {
1110-
throw new Error('Delete command requires id');
1110+
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'Delete command requires id' });
11111111
}
11121112
await this.delete(command.object, command.id, cmdOptions);
11131113
return {
@@ -1117,7 +1117,7 @@ export class MemoryDriver implements Driver {
11171117

11181118
case 'bulkCreate':
11191119
if (!command.records || !Array.isArray(command.records)) {
1120-
throw new Error('BulkCreate command requires records array');
1120+
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkCreate command requires records array' });
11211121
}
11221122
const bulkCreated = [];
11231123
for (const record of command.records) {
@@ -1132,7 +1132,7 @@ export class MemoryDriver implements Driver {
11321132

11331133
case 'bulkUpdate':
11341134
if (!command.updates || !Array.isArray(command.updates)) {
1135-
throw new Error('BulkUpdate command requires updates array');
1135+
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkUpdate command requires updates array' });
11361136
}
11371137
const updateResults = [];
11381138
for (const update of command.updates) {
@@ -1147,7 +1147,7 @@ export class MemoryDriver implements Driver {
11471147

11481148
case 'bulkDelete':
11491149
if (!command.ids || !Array.isArray(command.ids)) {
1150-
throw new Error('BulkDelete command requires ids array');
1150+
throw new ObjectQLError({ code: 'DRIVER_QUERY_FAILED', message: 'BulkDelete command requires ids array' });
11511151
}
11521152
let deleted = 0;
11531153
for (const id of command.ids) {
@@ -1160,7 +1160,7 @@ export class MemoryDriver implements Driver {
11601160
};
11611161

11621162
default:
1163-
throw new Error(`Unknown command type: ${(command as any).type}`);
1163+
throw new ObjectQLError({ code: 'DRIVER_UNSUPPORTED_OPERATION', message: `Unknown command type: ${(command as any).type}` });
11641164
}
11651165
} catch (error: any) {
11661166
return {
@@ -1181,6 +1181,6 @@ export class MemoryDriver implements Driver {
11811181
async execute(command: any, parameters?: any[], options?: any): Promise<any> {
11821182
// For memory driver, this is primarily for compatibility
11831183
// We don't support raw SQL/commands
1184-
throw new Error('Memory driver does not support raw command execution. Use executeCommand() instead.');
1184+
throw new ObjectQLError({ code: 'DRIVER_UNSUPPORTED_OPERATION', message: 'Memory driver does not support raw command execution. Use executeCommand() instead.' });
11851185
}
11861186
}

0 commit comments

Comments
 (0)