From 30c55856ea9d860ed746613da4e4b79093cd59f2 Mon Sep 17 00:00:00 2001 From: "fish.yu" Date: Thu, 18 Apr 2024 11:56:34 +0800 Subject: [PATCH] feat: remove try catch --- lib/download.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/download.js b/lib/download.js index 5f3ebf9..3310a29 100644 --- a/lib/download.js +++ b/lib/download.js @@ -156,21 +156,17 @@ class Downloader { } async uploadImageFromUrl(url) { - try { - // 获取图片后缀 - const pathname = new URL(url).pathname; - const suffix = '.' + pathname.split('.').pop(); - // 下载图片 - const content = await downloadImage(url); - const imageName = crypto.randomUUID() + suffix; - const imageUrl = `_images/${imageName}`; - // 上传到github - const result = await this.gh.writeFile(imageUrl, content, { encode: false }); - console.log('uploadImageFromUrl success:', result); - return `https://github.com/${imageUrl}`; - } catch (error) { - console.error('uploadImageFromUrl Error:', error); - } + // 获取图片后缀 + const pathname = new URL(url).pathname; + const suffix = '.' + pathname.split('.').pop(); + // 下载图片 + const content = await downloadImage(url); + const imageName = crypto.randomUUID() + suffix; + const imageUrl = `_images/${imageName}`; + // 上传到github + const result = await this.gh.writeFile(imageUrl, content, { encode: false }); + console.log('uploadImageFromUrl success:', result); + return `https://github.com/${imageUrl}`; } /**