diff --git a/src/devstar-api.ts b/src/devstar-api.ts index 1ddb900..62f6052 100644 --- a/src/devstar-api.ts +++ b/src/devstar-api.ts @@ -30,10 +30,15 @@ export default class DevstarAPIHandler { // 处理非200响应状态码 if (!response.ok) { const text = await response.text(); // 先读取文本防止json解析失败 - throw new Error(`HTTP Error: ${response.status} - ${text}`); + if (response.status == 401) { + throw new Error('Token错误') + } else { + throw new Error(`HTTP Error: ${response.status} - ${text}`); + } } - const data = await response.json(); + const responseData = await response.json(); + const data = responseData.data if (data.username == undefined || data.username == "") { throw new Error('Token对应用户不存在') } else {