* Checks for Evernote-specific exceptions in response struct fields 1-3.
(r: ThriftReader, fieldId: number, fieldType: number)
| 100 | * Checks for Evernote-specific exceptions in response struct fields 1-3. |
| 101 | */ |
| 102 | function checkException(r: ThriftReader, fieldId: number, fieldType: number): boolean { |
| 103 | if ((fieldId === 1 || fieldId === 2) && fieldType === TYPE_STRUCT) { |
| 104 | let errorCode = 0 |
| 105 | let message = '' |
| 106 | r.readStruct((r2, fid, ftype) => { |
| 107 | if (fid === 1 && ftype === TYPE_I32) errorCode = r2.readI32() |
| 108 | else if (fid === 2 && ftype === TYPE_STRING) message = r2.readString() |
| 109 | else r2.skip(ftype) |
| 110 | }) |
| 111 | throw new Error(`Evernote error (${errorCode}): ${message}`) |
| 112 | } |
| 113 | if (fieldId === 3 && fieldType === TYPE_STRUCT) { |
| 114 | let identifier = '' |
| 115 | r.readStruct((r2, fid, ftype) => { |
| 116 | if (fid === 1 && ftype === TYPE_STRING) identifier = r2.readString() |
| 117 | else r2.skip(ftype) |
| 118 | }) |
| 119 | throw new Error(`Evernote not found: ${identifier}`) |
| 120 | } |
| 121 | return false |
| 122 | } |
| 123 | |
| 124 | interface Notebook { |
| 125 | guid: string |
no test coverage detected