MCPcopy Index your code
hub / github.com/simstudioai/sim / checkEvernoteException

Function checkEvernoteException

apps/sim/app/api/tools/evernote/lib/client.ts:110–154  ·  view source on GitHub ↗

Check for Evernote-specific exceptions in the response struct. Returns true if handled.

(reader: ThriftReader, fieldId: number, fieldType: number)

Source from the content-addressed store, hash-verified

108
109/** Check for Evernote-specific exceptions in the response struct. Returns true if handled. */
110function checkEvernoteException(reader: ThriftReader, fieldId: number, fieldType: number): boolean {
111 if (fieldId === 1 && fieldType === TYPE_STRUCT) {
112 let message = ''
113 let errorCode = 0
114 reader.readStruct((r, fid, ftype) => {
115 if (fid === 1 && ftype === TYPE_I32) {
116 errorCode = r.readI32()
117 } else if (fid === 2 && ftype === TYPE_STRING) {
118 message = r.readString()
119 } else {
120 r.skip(ftype)
121 }
122 })
123 throw new Error(`Evernote error (${errorCode}): ${message}`)
124 }
125 if (fieldId === 2 && fieldType === TYPE_STRUCT) {
126 let message = ''
127 let errorCode = 0
128 reader.readStruct((r, fid, ftype) => {
129 if (fid === 1 && ftype === TYPE_I32) {
130 errorCode = r.readI32()
131 } else if (fid === 2 && ftype === TYPE_STRING) {
132 message = r.readString()
133 } else {
134 r.skip(ftype)
135 }
136 })
137 throw new Error(`Evernote system error (${errorCode}): ${message}`)
138 }
139 if (fieldId === 3 && fieldType === TYPE_STRUCT) {
140 let identifier = ''
141 let key = ''
142 reader.readStruct((r, fid, ftype) => {
143 if (fid === 1 && ftype === TYPE_STRING) {
144 identifier = r.readString()
145 } else if (fid === 2 && ftype === TYPE_STRING) {
146 key = r.readString()
147 } else {
148 r.skip(ftype)
149 }
150 })
151 throw new Error(`Evernote not found: ${identifier}${key ? ` (${key})` : ''}`)
152 }
153 return false
154}
155
156function readNotebook(reader: ThriftReader): EvernoteNotebook {
157 const notebook: EvernoteNotebook = {

Callers 11

listNotebooksFunction · 0.85
getNoteFunction · 0.85
createNoteFunction · 0.85
updateNoteFunction · 0.85
deleteNoteFunction · 0.85
searchNotesFunction · 0.85
getNotebookFunction · 0.85
createNotebookFunction · 0.85
listTagsFunction · 0.85
createTagFunction · 0.85
copyNoteFunction · 0.85

Calls 4

readStructMethod · 0.80
readI32Method · 0.80
readStringMethod · 0.80
skipMethod · 0.80

Tested by

no test coverage detected