Skip to content

Commit

Permalink
fix(exception): missing message field after refactoring exception d…
Browse files Browse the repository at this point in the history
…ata structure
  • Loading branch information
qwqcode committed Mar 4, 2024
1 parent 929faf0 commit 5bf6e5f
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 15 deletions.
14 changes: 13 additions & 1 deletion docs/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2504,7 +2504,7 @@ const docTemplate = `{
{
"type": "object",
"properties": {
" data": {
"data": {
"type": "object",
"properties": {
"need_name_select": {
Expand Down Expand Up @@ -3219,6 +3219,7 @@ const docTemplate = `{
"is_collapsed",
"is_pending",
"is_pinned",
"is_verified",
"link",
"nick",
"page_key",
Expand Down Expand Up @@ -3268,6 +3269,9 @@ const docTemplate = `{
"is_pinned": {
"type": "boolean"
},
"is_verified": {
"type": "boolean"
},
"link": {
"type": "string"
},
Expand Down Expand Up @@ -3978,6 +3982,7 @@ const docTemplate = `{
"is_collapsed",
"is_pending",
"is_pinned",
"is_verified",
"link",
"nick",
"page_key",
Expand Down Expand Up @@ -4027,6 +4032,9 @@ const docTemplate = `{
"is_pinned": {
"type": "boolean"
},
"is_verified": {
"type": "boolean"
},
"link": {
"type": "string"
},
Expand Down Expand Up @@ -4128,6 +4136,7 @@ const docTemplate = `{
"is_collapsed",
"is_pending",
"is_pinned",
"is_verified",
"link",
"nick",
"page_key",
Expand Down Expand Up @@ -4177,6 +4186,9 @@ const docTemplate = `{
"is_pinned": {
"type": "boolean"
},
"is_verified": {
"type": "boolean"
},
"link": {
"type": "string"
},
Expand Down
14 changes: 13 additions & 1 deletion docs/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2497,7 +2497,7 @@
{
"type": "object",
"properties": {
" data": {
"data": {
"type": "object",
"properties": {
"need_name_select": {
Expand Down Expand Up @@ -3212,6 +3212,7 @@
"is_collapsed",
"is_pending",
"is_pinned",
"is_verified",
"link",
"nick",
"page_key",
Expand Down Expand Up @@ -3261,6 +3262,9 @@
"is_pinned": {
"type": "boolean"
},
"is_verified": {
"type": "boolean"
},
"link": {
"type": "string"
},
Expand Down Expand Up @@ -3971,6 +3975,7 @@
"is_collapsed",
"is_pending",
"is_pinned",
"is_verified",
"link",
"nick",
"page_key",
Expand Down Expand Up @@ -4020,6 +4025,9 @@
"is_pinned": {
"type": "boolean"
},
"is_verified": {
"type": "boolean"
},
"link": {
"type": "string"
},
Expand Down Expand Up @@ -4121,6 +4129,7 @@
"is_collapsed",
"is_pending",
"is_pinned",
"is_verified",
"link",
"nick",
"page_key",
Expand Down Expand Up @@ -4170,6 +4179,9 @@
"is_pinned": {
"type": "boolean"
},
"is_verified": {
"type": "boolean"
},
"link": {
"type": "string"
},
Expand Down
11 changes: 10 additions & 1 deletion docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ definitions:
type: boolean
is_pinned:
type: boolean
is_verified:
type: boolean
link:
type: string
nick:
Expand Down Expand Up @@ -98,6 +100,7 @@ definitions:
- is_collapsed
- is_pending
- is_pinned
- is_verified
- link
- nick
- page_key
Expand Down Expand Up @@ -611,6 +614,8 @@ definitions:
type: boolean
is_pinned:
type: boolean
is_verified:
type: boolean
link:
type: string
nick:
Expand Down Expand Up @@ -646,6 +651,7 @@ definitions:
- is_collapsed
- is_pending
- is_pinned
- is_verified
- link
- nick
- page_key
Expand Down Expand Up @@ -716,6 +722,8 @@ definitions:
type: boolean
is_pinned:
type: boolean
is_verified:
type: boolean
link:
type: string
nick:
Expand Down Expand Up @@ -751,6 +759,7 @@ definitions:
- is_collapsed
- is_pending
- is_pinned
- is_verified
- link
- nick
- page_key
Expand Down Expand Up @@ -2568,7 +2577,7 @@ paths:
allOf:
- $ref: '#/definitions/handler.Map'
- properties:
' data':
data:
properties:
need_name_select:
items:
Expand Down
6 changes: 3 additions & 3 deletions ui/artalk-sidebar/src/components/PageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function editAdminOnly() {
try {
p = (await artalk!.ctx.getApi().pages.updatePage(page.value.id, { ...page.value, admin_only: !page.value.admin_only })).data
} catch (err: any) {
alert(`修改失败:${err.msg || '未知错误'}`)
alert(`修改失败:${err.message || '未知错误'}`)
console.log(err)
return
} finally { isLoading.value = false }
Expand All @@ -45,7 +45,7 @@ async function sync() {
try {
p = (await artalk!.ctx.getApi().pages.fetchPage(page.value.id)).data
} catch (err: any) {
alert(`同步失败:${err.msg || '未知错误'}`)
alert(`同步失败:${err.message || '未知错误'}`)
console.log(err)
return
} finally { isLoading.value = false }
Expand Down Expand Up @@ -80,7 +80,7 @@ async function onFieldEditorYes(val: string) {
try {
p = (await artalk!.ctx.getApi().pages.updatePage(page.value.id, { ...page.value, [editFieldKey.value as any]: val })).data
} catch (err: any) {
alert(`修改失败:${err.msg || '未知错误'}`)
alert(`修改失败:${err.message || '未知错误'}`)
console.error(err)
return false
} finally { isLoading.value = false }
Expand Down
2 changes: 1 addition & 1 deletion ui/artalk-sidebar/src/components/SiteCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function submit() {
urls: siteUrls
})).data
} catch (err: any) {
window.alert(`创建失败:${err.msg || ''}`)
window.alert(`创建失败:${err.message || ''}`)
console.error(err)
return
} finally { isLoading.value = false }
Expand Down
2 changes: 1 addition & 1 deletion ui/artalk-sidebar/src/components/SiteEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function onFieldEditorYes(val: string) {
if (Array.isArray(site.value[editFieldKey.value])) finalVal = val.split(',').map((v) => v.trim()).filter((v) => !!v)
s = (await artalk!.ctx.getApi().sites.updateSite(site.value.id, { ...site.value, [editFieldKey.value]: finalVal })).data
} catch (err: any) {
alert(`修改失败:${err.msg || '未知错误'}`)
alert(`修改失败:${err.message || '未知错误'}`)
console.error(err)
return false
} finally { isLoading.value = false }
Expand Down
4 changes: 2 additions & 2 deletions ui/artalk-sidebar/src/pages/users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function delUser(user: ArtalkType.UserDataForAdmin) {
alert('用户已从数据库删除,请手动编辑配置文件并删除用户')
}
})
.catch((e) => {
alert('删除失败:'+e.msg)
.catch((e: ArtalkType.FetchError) => {
alert('删除失败:'+e.message)
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions ui/artalk/src/api/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
* @request POST:/user/access_token
* @response `200` `HandlerResponseUserLogin` OK
* @response `400` `(HandlerMap & {
" data"?: {
data?: {
need_name_select?: (string)[],
},
Expand All @@ -1975,7 +1975,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
this.request<
HandlerResponseUserLogin,
| (HandlerMap & {
' data'?: {
data?: {
need_name_select?: string[]
}
msg?: string
Expand Down
2 changes: 1 addition & 1 deletion ui/artalk/src/plugins/editor/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class Submit extends EditorPlug {
} catch (err: any) {
// submit error
console.error(err)
this.kit.useEditor().showNotify(`${$t('commentFail')}: ${err.msg || String(err)}`, 'e')
this.kit.useEditor().showNotify(`${$t('commentFail')}: ${err.message || String(err)}`, 'e')
return
} finally {
this.kit.useEditor().hideLoading()
Expand Down
2 changes: 1 addition & 1 deletion ui/artalk/src/plugins/editor/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class Upload extends EditorPlug {
}
} catch (err: any) {
console.error(err)
this.kit.useEditor().showNotify(`${$t('uploadFail')}: ${err.msg}`, 'e')
this.kit.useEditor().showNotify(`${$t('uploadFail')}: ${err.message}`, 'e')
}
if (!!resp && resp.public_url) {
let imgURL = resp.public_url as string
Expand Down
2 changes: 1 addition & 1 deletion ui/artalk/src/plugins/list/with-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function adminPageEditSave(ctx: ContextApi, page: PageData) {
ctx.getData().updatePage(data)
})
.catch(err => {
ctx.editorShowNotify(`${$t('editFail')}: ${err.msg || String(err)}`, 'e')
ctx.editorShowNotify(`${$t('editFail')}: ${err.message || String(err)}`, 'e')
})
.finally(() => {
ctx.editorHideLoading()
Expand Down

0 comments on commit 5bf6e5f

Please sign in to comment.