|
165 | 165 | putError.call(this, e.message); |
166 | 166 | } |
167 | 167 | } |
168 | | - tmpSheet = SpreadsheetApp.openById(tmpId) |
169 | | - .getSheets()[0] |
170 | | - .setName(`SpreadsheetAppp_${Utilities.getUuid()}`) |
171 | | - .copyTo(dstSS); |
172 | | - Drive.Files.remove(tmpId); |
| 168 | + try { |
| 169 | + const tmpSpreadsheet = SpreadsheetAppp.openById(tmpId); |
| 170 | + tmpSheet = tmpSpreadsheet.getSheets()[0]; |
| 171 | + tmpSheet.setName(`SpreadsheetAppp_${Utilities.getUuid()}`); |
| 172 | + tmpSheet.copyTo(dstSS); |
| 173 | + |
| 174 | + Drive.Files.remove(tmpId); |
| 175 | + } catch (err) { |
| 176 | + // in case of failure remove Temp generated file to avoid spamming |
| 177 | + console.log( |
| 178 | + "[DocsServiceApp]", |
| 179 | + "Error copying tmp file into destination", |
| 180 | + err.name, |
| 181 | + err.message |
| 182 | + ); |
| 183 | + |
| 184 | + if (tmpId) { |
| 185 | + Drive.Files.remove(tmpId); |
| 186 | + } |
| 187 | + |
| 188 | + throw err; |
| 189 | + } |
173 | 190 | tmpSheetId = tmpSheet.getSheetId(); |
174 | 191 | requests = ar.map((e) => { |
175 | 192 | e.from.sheetId = tmpSheetId; |
|
249 | 266 | gToM = function () { |
250 | 267 | var obj, url; |
251 | 268 | url = `https://www.googleapis.com/drive/v3/files/${this.obj.spreadsheetId}/export?mimeType=${MimeType.MICROSOFT_EXCEL}`; |
252 | | - console.log( |
253 | | - "[FPR-859] Requesting MS export", |
254 | | - "Library object ->", |
255 | | - JSON.stringify(this.obj || {}), |
256 | | - "Request URL ->", |
257 | | - url |
258 | | - ) |
259 | | - try { |
260 | | - console.log("[FPR-859] Request headers -> ", JSON.stringify(this.headers || {})) |
261 | | - obj = UrlFetchApp.fetch(url, { |
262 | | - headers: this.headers, |
263 | | - }); |
264 | | - console.log("[FPR-859] Successfull MS file export response ->", obj.getResponseCode()) |
265 | | - } catch (err) { |
266 | | - console.log("[FPR-859] Errored MS file export response -> ", obj.getResponseCode()) |
267 | | - } |
| 269 | + console.log( |
| 270 | + "[FPR-859] Requesting MS export", |
| 271 | + "Library object ->", |
| 272 | + JSON.stringify(this.obj || {}), |
| 273 | + "Request URL ->", |
| 274 | + url |
| 275 | + ); |
| 276 | + try { |
| 277 | + console.log( |
| 278 | + "[FPR-859] Request headers -> ", |
| 279 | + JSON.stringify(this.headers || {}) |
| 280 | + ); |
| 281 | + obj = UrlFetchApp.fetch(url, { |
| 282 | + headers: this.headers, |
| 283 | + }); |
| 284 | + console.log( |
| 285 | + "[FPR-859] Successfull MS file export response ->", |
| 286 | + obj.getResponseCode() |
| 287 | + ); |
| 288 | + } catch (err) { |
| 289 | + console.log( |
| 290 | + "[FPR-859] Errored MS file export response -> ", |
| 291 | + obj.getResponseCode() |
| 292 | + ); |
| 293 | + } |
268 | 294 | if (obj.getResponseCode() !== 200) { |
269 | 295 | putError.call( |
270 | 296 | this, |
|
0 commit comments