Skip to content

Commit 6f4d63f

Browse files
feat(linear): adopt IntegrationError classes in remaining Linear files
- auto-sync.ts: 5 errors updated (auth/sync) - migration.ts: 2 errors updated (sync) - rest-client.ts: 2 errors updated (api) - sync.ts: 1 error updated (sync) - webhook.ts: 2 errors updated (webhook) - webhook-handler.ts: 1 error updated (webhook) - webhook-server.ts: 1 error updated (webhook) - oauth-server.ts: 3 errors updated (auth)
1 parent 9aeae63 commit 6f4d63f

8 files changed

Lines changed: 341 additions & 184 deletions

File tree

src/integrations/linear/auto-sync.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { LinearTaskManager } from '../../features/tasks/linear-task-manager.js';
88
import { LinearAuthManager } from './auth.js';
99
import { LinearSyncEngine, DEFAULT_SYNC_CONFIG, SyncConfig } from './sync.js';
1010
import { LinearConfigManager } from './config.js';
11+
import { IntegrationError, ErrorCode } from '../../core/errors/index.js';
1112
import Database from 'better-sqlite3';
1213
import { join } from 'path';
1314
import { existsSync } from 'fs';
@@ -74,16 +75,18 @@ export class LinearAutoSyncService {
7475
// Verify Linear integration is configured
7576
const authManager = new LinearAuthManager(this.projectRoot);
7677
if (!authManager.isConfigured()) {
77-
throw new Error(
78-
'Linear integration not configured. Run "stackmemory linear setup" first.'
78+
throw new IntegrationError(
79+
'Linear integration not configured. Run "stackmemory linear setup" first.',
80+
ErrorCode.LINEAR_AUTH_FAILED
7981
);
8082
}
8183

8284
// Initialize sync engine
8385
const dbPath = join(this.projectRoot, '.stackmemory', 'context.db');
8486
if (!existsSync(dbPath)) {
85-
throw new Error(
86-
'StackMemory not initialized. Run "stackmemory init" first.'
87+
throw new IntegrationError(
88+
'StackMemory not initialized. Run "stackmemory init" first.',
89+
ErrorCode.LINEAR_SYNC_FAILED
8790
);
8891
}
8992

@@ -99,8 +102,9 @@ export class LinearAutoSyncService {
99102
// Test connection before starting
100103
const token = await authManager.getValidToken();
101104
if (!token) {
102-
throw new Error(
103-
'Unable to get valid Linear token. Check authentication.'
105+
throw new IntegrationError(
106+
'Unable to get valid Linear token. Check authentication.',
107+
ErrorCode.LINEAR_AUTH_FAILED
104108
);
105109
}
106110

@@ -177,7 +181,10 @@ export class LinearAutoSyncService {
177181
*/
178182
async forceSync(): Promise<void> {
179183
if (!this.syncEngine) {
180-
throw new Error('Sync engine not initialized');
184+
throw new IntegrationError(
185+
'Sync engine not initialized',
186+
ErrorCode.LINEAR_SYNC_FAILED
187+
);
181188
}
182189

183190
logger.info('Forcing immediate Linear sync');
@@ -252,7 +259,10 @@ export class LinearAutoSyncService {
252259
});
253260
}
254261
} else {
255-
throw new Error(`Sync failed: ${result.errors.join(', ')}`);
262+
throw new IntegrationError(
263+
`Sync failed: ${result.errors.join(', ')}`,
264+
ErrorCode.LINEAR_SYNC_FAILED
265+
);
256266
}
257267
} catch (error: unknown) {
258268
logger.error('Linear auto-sync failed:', error as Error);

0 commit comments

Comments
 (0)