@@ -12,7 +12,6 @@ import { NotebookOpenedIconSvg } from './icons/notebookOpenedIcon.svg';
12
12
import { NotebookClosedIconSvg } from './icons/notebookClosedIcon.svg' ;
13
13
import { ChevronSvg } from './icons/chevron.svg' ;
14
14
import { CreateNewSectionNode } from './createNewSection/createNewSectionNode' ;
15
- import * as OneNoteApi from 'onenoteapi' ;
16
15
import { SpinnerIconSvg } from './icons/spinnerIcon.svg' ;
17
16
import { Strings } from '../strings' ;
18
17
@@ -46,8 +45,8 @@ export class NotebookRenderStrategy implements ExpandableNodeRenderStrategy {
46
45
}
47
46
48
47
getChildren ( childrenLevel : number ) : JSX . Element [ ] {
49
- if ( typeof ( this . notebook . apiHttpErrorCode ) === 'number' ) {
50
- const errorString = Strings . getError ( this . notebook . apiHttpErrorCode ) ;
48
+ if ( this . notebook . apiHttpErrorMessage ) {
49
+ const errorString = this . notebook . apiHttpErrorMessage ;
51
50
return [
52
51
< li role = 'status' aria-live = 'polite' aria-label = { errorString } className = 'progress-row' >
53
52
< div > { errorString } </ div >
@@ -144,15 +143,19 @@ export class NotebookRenderStrategy implements ExpandableNodeRenderStrategy {
144
143
}
145
144
146
145
private onExpand ( ) {
147
- if ( this . notebook . needsToFetchChildren && this . notebook . apiUrl && this . globals . oneNoteDataProvider && ! ! this . globals . callbacks . onNotebookInfoReturned ) {
146
+ if ( this . notebook . needsToFetchChildren && this . notebook . apiUrl && this . globals . oneNoteDataProvider ) {
148
147
this . globals . oneNoteDataProvider . getNotebookBySelfUrl ( this . notebook . apiUrl , 5 ) . then ( ( notebook ) => {
149
148
this . notebook . sections = notebook . sections
150
149
this . notebook . sectionGroups = notebook . sectionGroups
151
- } ) . catch ( ( apiError : OneNoteApi . RequestError ) => {
152
- this . notebook . apiHttpErrorCode = apiError . statusCode ;
150
+ } ) . catch ( ( apiError : any ) => {
151
+ try {
152
+ this . notebook . apiHttpErrorMessage = JSON . parse ( apiError . response ) . error . message
153
+ } catch ( error ) {
154
+ this . notebook . apiHttpErrorMessage = Strings . getError ( apiError . statusCode ) ;
155
+ }
153
156
} ) . then ( ( ) => {
154
157
this . notebook . needsToFetchChildren = false ;
155
- if ( ! ! this . globals . callbacks . onNotebookInfoReturned ) {
158
+ if ( this . globals . callbacks . onNotebookInfoReturned ) {
156
159
this . globals . callbacks . onNotebookInfoReturned ( this . notebook ) ;
157
160
}
158
161
} )
0 commit comments