@@ -63,12 +63,13 @@ export class ConfluenceLoader extends BaseLoader<{ type: 'ConfluenceLoader' }, {
6363
6464 private async * processSpace ( spaceKey : string ) {
6565 this . debug ( 'Processing space' , spaceKey ) ;
66+
6667 try {
6768 const spaceContent = await this . confluence . space . getContentForSpace ( { spaceKey } ) ;
6869 this . debug ( `Confluence space '${ spaceKey } ' has '${ spaceContent [ 'page' ] . results . length } ' root pages` ) ;
6970
70- for ( const { id } of spaceContent [ 'page' ] . results ) {
71- for await ( const result of this . processPage ( id ) ) {
71+ for ( const { id, title } of spaceContent [ 'page' ] . results ) {
72+ for await ( const result of this . processPage ( id , title ) ) {
7273 yield result ;
7374 }
7475 }
@@ -78,8 +79,10 @@ export class ConfluenceLoader extends BaseLoader<{ type: 'ConfluenceLoader' }, {
7879 }
7980 }
8081
81- private async * processPage ( pageId : string ) {
82+ private async * processPage ( pageId : string , title : string ) {
83+ this . debug ( 'Processing page' , title ) ;
8284 let confluenceVersion = 0 ;
85+
8386 try {
8487 const spaceProperties = await this . confluence . content . getContentById ( {
8588 id : pageId ,
@@ -89,29 +92,29 @@ export class ConfluenceLoader extends BaseLoader<{ type: 'ConfluenceLoader' }, {
8992 if ( ! spaceProperties . version . number ) throw new Error ( 'Version number not found in space properties...' ) ;
9093 confluenceVersion = spaceProperties . version . number ;
9194 } catch ( e ) {
92- this . debug ( 'Could not get page properties. Page will be SKIPPED!' , pageId , e . response ) ;
95+ this . debug ( 'Could not get page properties. Page will be SKIPPED!' , title , e . response ) ;
9396 return ;
9497 }
9598
9699 let doProcess = false ;
97100 if ( ! ( await this . checkInCache ( pageId ) ) ) {
98- this . debug ( `Processing '${ pageId } ' for the FIRST time...` ) ;
101+ this . debug ( `Processing '${ title } ' for the FIRST time...` ) ;
99102 doProcess = true ;
100103 } else {
101104 const cacheVersion = ( await this . getFromCache ( pageId ) ) . version ;
102105 if ( cacheVersion !== confluenceVersion ) {
103106 this . debug (
104- `For page '${ pageId } ' - version in cache is ${ cacheVersion } and confluence version is ${ confluenceVersion } . This page will be PROCESSED.` ,
107+ `For page '${ title } ' - version in cache is ${ cacheVersion } and confluence version is ${ confluenceVersion } . This page will be PROCESSED.` ,
105108 ) ;
106109 doProcess = true ;
107110 } else
108111 this . debug (
109- `For page '${ pageId } ' - version in cache and confluence are the same ${ confluenceVersion } . This page will be SKIPPED.` ,
112+ `For page '${ title } ' - version in cache and confluence are the same ${ confluenceVersion } . This page will be SKIPPED.` ,
110113 ) ;
111114 }
112115
113116 if ( ! doProcess ) {
114- this . debug ( `Skipping page '${ pageId } '` ) ;
117+ this . debug ( `Skipping page '${ title } '` ) ;
115118 return ;
116119 }
117120
@@ -126,21 +129,27 @@ export class ConfluenceLoader extends BaseLoader<{ type: 'ConfluenceLoader' }, {
126129 return ;
127130 }
128131
132+ this . debug ( `Processing content for page '${ title } '...` ) ;
129133 for await ( const result of this . getContentChunks ( content . body . view . value , content . _links . webui ) ) {
130134 yield result ;
131135 }
132136
133137 await this . saveToCache ( pageId , { version : confluenceVersion } ) ;
134138
135139 if ( content . children ) {
136- for ( const { id } of content . children . page . results ) {
137- for await ( const result of this . processPage ( id ) ) {
138- yield result ;
140+ for ( const { id, title } of content . children . page . results ) {
141+ try {
142+ for await ( const result of this . processPage ( id , title ) ) {
143+ yield result ;
144+ }
145+ } catch ( e ) {
146+ this . debug ( `Error! Could not process page child '${ title } '` , pageId , e ) ;
147+ return ;
139148 }
140149 }
141150 }
142151 } catch ( e ) {
143- this . debug ( 'Error! Could not process page content or children ' , pageId , e ) ;
152+ this . debug ( 'Error! Could not process page content' , pageId , e ) ;
144153 return ;
145154 }
146155 }
0 commit comments