Error handling enhancement. Closes #42 Resolves #18 (#44)

Signed-off-by: Kuba Wolanin <hi@kubawolanin.com>
pull/45/head
Kuba Wolanin 2017-10-27 20:18:52 +02:00 committed by GitHub
parent 27bff8f446
commit 2b102cb081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -64,12 +64,13 @@ export class ItemsModel {
}.bind(this))
.catch(async err => {
let config = workspace.getConfiguration('openhab')
const openSettings = 'Open Settings'
const setHost = 'Set openHAB host'
const disableRest = 'Disable REST API'
const result = await window.showErrorMessage('Error while connecting to openHAB REST API. ', openSettings, disableRest)
const result = await window.showErrorMessage('Error while connecting to openHAB REST API. ', setHost, disableRest)
switch (result) {
case openSettings:
commands.executeCommand('workbench.action.openGlobalSettings')
case setHost:
config.update('host', 'localhost')
commands.executeCommand('workbench.action.openWorkspaceSettings')
break
case disableRest:
config.update('useRestApi', false)

View File

@ -74,6 +74,15 @@ export function hasExtension(name: string): Thenable<boolean> {
})
}
export function getSitemaps(): Thenable<any[]> {
return new Promise((resolve, reject) => {
request(getHost() + '/rest/sitemaps')
.then((response) => {
resolve(JSON.parse(response))
}).catch(() => reject([]))
})
}
export function openHtml(uri: Uri, title) {
return commands.executeCommand('vscode.previewHtml', uri, ViewColumn.Two, title)
.then((success) => {

View File

@ -433,7 +433,7 @@
"name": "keyword.control.openhab"
},
{
"match": "\\b(return|break|case|continue|default|do|while|for|switch|if|else)\\b",
"match": "\\b((?!<)(return|break|case|continue|default|do|while|for|switch|if|else)(?!>))\\b",
"name": "keyword.control.openhab"
},
{