@@ -106,8 +106,8 @@ async function callNoteStore(token: string, writer: ThriftWriter): Promise<Thrif
106106 return reader
107107}
108108
109- /** Check for Evernote-specific exceptions in the response struct */
110- function checkEvernoteException ( reader : ThriftReader , fieldId : number , fieldType : number ) : void {
109+ /** Check for Evernote-specific exceptions in the response struct. Returns true if handled. */
110+ function checkEvernoteException ( reader : ThriftReader , fieldId : number , fieldType : number ) : boolean {
111111 if ( fieldId === 1 && fieldType === TYPE_STRUCT ) {
112112 let message = ''
113113 let errorCode = 0
@@ -150,6 +150,7 @@ function checkEvernoteException(reader: ThriftReader, fieldId: number, fieldType
150150 } )
151151 throw new Error ( `Evernote not found: ${ identifier } ${ key ? ` (${ key } )` : '' } ` )
152152 }
153+ return false
153154}
154155
155156function readNotebook ( reader : ThriftReader ) : EvernoteNotebook {
@@ -382,8 +383,9 @@ export async function listNotebooks(token: string): Promise<EvernoteNotebook[]>
382383 notebooks . push ( readNotebook ( r ) )
383384 }
384385 } else {
385- checkEvernoteException ( r , fieldId , fieldType )
386- r . skip ( fieldType )
386+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
387+ r . skip ( fieldType )
388+ }
387389 }
388390 } )
389391
@@ -412,8 +414,9 @@ export async function getNote(
412414 if ( fieldId === 0 && fieldType === TYPE_STRUCT ) {
413415 note = readNote ( r )
414416 } else {
415- checkEvernoteException ( r , fieldId , fieldType )
416- r . skip ( fieldType )
417+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
418+ r . skip ( fieldType )
419+ }
417420 }
418421 } )
419422
@@ -468,8 +471,9 @@ export async function createNote(
468471 if ( fieldId === 0 && fieldType === TYPE_STRUCT ) {
469472 note = readNote ( r )
470473 } else {
471- checkEvernoteException ( r , fieldId , fieldType )
472- r . skip ( fieldType )
474+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
475+ r . skip ( fieldType )
476+ }
473477 }
474478 } )
475479
@@ -517,8 +521,9 @@ export async function updateNote(
517521 if ( fieldId === 0 && fieldType === TYPE_STRUCT ) {
518522 note = readNote ( r )
519523 } else {
520- checkEvernoteException ( r , fieldId , fieldType )
521- r . skip ( fieldType )
524+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
525+ r . skip ( fieldType )
526+ }
522527 }
523528 } )
524529
@@ -543,8 +548,9 @@ export async function deleteNote(token: string, guid: string): Promise<number> {
543548 if ( fieldId === 0 && fieldType === TYPE_I32 ) {
544549 usn = r . readI32 ( )
545550 } else {
546- checkEvernoteException ( r , fieldId , fieldType )
547- r . skip ( fieldType )
551+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
552+ r . skip ( fieldType )
553+ }
548554 }
549555 } )
550556
@@ -623,8 +629,9 @@ export async function searchNotes(
623629 }
624630 } )
625631 } else {
626- checkEvernoteException ( r , fieldId , fieldType )
627- r . skip ( fieldType )
632+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
633+ r . skip ( fieldType )
634+ }
628635 }
629636 } )
630637
@@ -645,8 +652,9 @@ export async function getNotebook(token: string, guid: string): Promise<Evernote
645652 if ( fieldId === 0 && fieldType === TYPE_STRUCT ) {
646653 notebook = readNotebook ( r )
647654 } else {
648- checkEvernoteException ( r , fieldId , fieldType )
649- r . skip ( fieldType )
655+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
656+ r . skip ( fieldType )
657+ }
650658 }
651659 } )
652660
@@ -682,8 +690,9 @@ export async function createNotebook(
682690 if ( fieldId === 0 && fieldType === TYPE_STRUCT ) {
683691 notebook = readNotebook ( r )
684692 } else {
685- checkEvernoteException ( r , fieldId , fieldType )
686- r . skip ( fieldType )
693+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
694+ r . skip ( fieldType )
695+ }
687696 }
688697 } )
689698
@@ -710,8 +719,9 @@ export async function listTags(token: string): Promise<EvernoteTag[]> {
710719 tags . push ( readTag ( r ) )
711720 }
712721 } else {
713- checkEvernoteException ( r , fieldId , fieldType )
714- r . skip ( fieldType )
722+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
723+ r . skip ( fieldType )
724+ }
715725 }
716726 } )
717727
@@ -743,8 +753,9 @@ export async function createTag(
743753 if ( fieldId === 0 && fieldType === TYPE_STRUCT ) {
744754 tag = readTag ( r )
745755 } else {
746- checkEvernoteException ( r , fieldId , fieldType )
747- r . skip ( fieldType )
756+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
757+ r . skip ( fieldType )
758+ }
748759 }
749760 } )
750761
@@ -774,8 +785,9 @@ export async function copyNote(
774785 if ( fieldId === 0 && fieldType === TYPE_STRUCT ) {
775786 note = readNote ( r )
776787 } else {
777- checkEvernoteException ( r , fieldId , fieldType )
778- r . skip ( fieldType )
788+ if ( ! checkEvernoteException ( r , fieldId , fieldType ) ) {
789+ r . skip ( fieldType )
790+ }
779791 }
780792 } )
781793
0 commit comments