@@ -7,29 +7,38 @@ workerServer.once('init', async (frontendURL) => {
77 const parser = await new JSDocParser ( ) . init ( `${ frontendURL } types/libs.d.ts` ) ;
88
99 workerServer . on ( 'attributes:parse' , async ( guid , scriptContents , deletedFiles , url ) => {
10- parser . updateProgram ( scriptContents , deletedFiles ) ;
11- const [ attributes , errors ] = await parser . parseAttributes ( url ) ;
12-
13- // Parse the results
14- const scripts = Object . keys ( attributes ) . reduce ( ( acc , key ) => {
15- const script = attributes [ key ] ;
16- const attributesOrder = Object . keys ( script . attributes ) ;
17- acc [ key ] = {
18- attributesInvalid : [ ] ,
19- attributesOrder,
20- attributes : script . attributes
21- } ;
22- return acc ;
23- } , { } ) ;
24-
25- const scriptsInvalid = errors . map ( ( error ) => {
26- if ( ! error . file ) {
27- return error . message ;
28- }
29- return `${ error . file } (${ error . line + 1 } ,${ error . column + 1 } ) [JavaScript]: ${ error . message } ` ;
30- } ) ;
31-
32- workerServer . send ( 'attributes:parse' , guid , scripts , scriptsInvalid ) ;
10+ try {
11+ parser . updateProgram ( scriptContents , deletedFiles ) ;
12+ const [ attributes , errors ] = await parser . parseAttributes ( url ) ;
13+
14+ // Parse the results
15+ const scripts = Object . keys ( attributes ) . reduce ( ( acc , key ) => {
16+ const script = attributes [ key ] ;
17+ const attributesOrder = Object . keys ( script . attributes ) ;
18+ acc [ key ] = {
19+ attributesInvalid : [ ] ,
20+ attributesOrder,
21+ attributes : script . attributes
22+ } ;
23+ return acc ;
24+ } , { } ) ;
25+
26+ const scriptsInvalid = errors . map ( ( error ) => {
27+ if ( ! error . file ) {
28+ return error . message ;
29+ }
30+ return `${ error . file } (${ error . line + 1 } ,${ error . column + 1 } ) [JavaScript]: ${ error . message } ` ;
31+ } ) ;
32+
33+ workerServer . send ( 'attributes:parse' , guid , scripts , scriptsInvalid ) ;
34+
35+ } catch ( error ) {
36+ const errorMessage = error instanceof Error ?
37+ 'The Attribute Parser failed unexpectedly.' :
38+ `Attribute parsing error: ${ error . toString ( ) } ` ;
39+
40+ workerServer . send ( 'attributes:parse' , guid , { } , [ errorMessage ] ) ;
41+ }
3342 } ) ;
3443
3544 workerServer . on ( 'attributes:get' , ( asn , uri , fileName , scriptContents , deletedFiles ) => {
0 commit comments