@@ -8,6 +8,7 @@ import { LinearTaskManager } from '../../features/tasks/linear-task-manager.js';
88import { LinearAuthManager } from './auth.js' ;
99import { LinearSyncEngine , DEFAULT_SYNC_CONFIG , SyncConfig } from './sync.js' ;
1010import { LinearConfigManager } from './config.js' ;
11+ import { IntegrationError , ErrorCode } from '../../core/errors/index.js' ;
1112import Database from 'better-sqlite3' ;
1213import { join } from 'path' ;
1314import { 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