Skip to content

Commit

Permalink
feat: readable error in frontend
Browse files Browse the repository at this point in the history
Signed-off-by: SettingDust <[email protected]>
  • Loading branch information
SettingDust committed Dec 1, 2022
1 parent 83c858d commit 65e3fc9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "obsidian-web-clipper",
"packageManager": "[email protected]",
"type": "module",
"version": "1.0.2",
"version": "1.0.3",
"scripts": {
"ng": "ng",
"lint": "cd ./dist && web-ext lint",
Expand Down
4 changes: 2 additions & 2 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@
"message": "Can't connect to server. Please confirm Obsidian is running, installed Local REST API plugin in Obsidian and check url option"
},
"errorNoPermission": {
"message": "Can't get extension permission"
"message": "Can't get extension permission. Please click request permission in options page"
},
"errorNoToken": {
"message": "No or wrong token"
"message": "No or wrong Local REST API token. Please find it in Obsidian settings"
}
}
4 changes: 2 additions & 2 deletions src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@
"message": "无法连接服务器,请确认 Obsidian 已启动,且装有 Local REST API 插件,并检查 URL 设置"
},
"errorNoPermission": {
"message": "无法获取扩展域名访问权限"
"message": "无法获取扩展域名访问权限,请在设置中点击请求权限按钮"
},
"errorNoToken": {
"message": "令牌缺失或错误"
"message": "Local REST API 令牌缺失或错误,请在 Obsidian 设置中查看插件设置"
}
}
3 changes: 2 additions & 1 deletion src/app/background/background.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class BackgroundComponent {
),
catchError((error: unknown) => {
if (sender?.tab?.id) extensionService.message.action(sender.tab.id, 'error', error)
return throwError(() => error)
console.warn(error)
return of(null)
})
)
)
Expand Down
7 changes: 0 additions & 7 deletions src/content-scripts/error-action.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import { ActionData } from '../action'
import $background from './background-listener'

$background.message.actionListener('error').subscribe(({ message, respond }) => {
// TODO: popup of error
console.warn('[obsidian-web-clipper:error]', message)
respond()
})

export type ErrorBackgroundAction = ActionData<
{
Expand Down
10 changes: 10 additions & 0 deletions src/content-scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import './background-listener'
import './shortcuts'
import $background from './background-listener'

console.debug('[obsidian-web-clipper]: Loaded')

$background.message.actionListener('error').subscribe(({ message, respond }) => {
console.warn('[obsidian-web-clipper:error]', message)
const finalMessage = typeof message === 'string' ? message : message?.data?.message
if (finalMessage) {
alert(`[Obsidian Web Clipper] ${finalMessage}`)
}
respond()
})
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/PrsPrsBK/ffext-manifest-schema/master/ffext.json",
"manifest_version": 2,
"name": "__MSG_extensionName__",
"version": "1.0.2",
"version": "1.0.3",
"description": "__MSG_extensionDescription__",
"permissions": [
"tabs",
Expand Down

0 comments on commit 65e3fc9

Please sign in to comment.