summaryrefslogtreecommitdiff
path: root/translate-widget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2017-12-27 13:30:56 -0500
committerstreetturtle <streetturtle@gmail.com>2017-12-27 13:30:56 -0500
commit35af74ff3b35891196fb65c9259a199c0dba54da (patch)
tree6e46ce82664c45522536852ea26ae3df64fc6130 /translate-widget
parentf49e4ee31e406e69f2d7f6b2b2683206f203ae67 (diff)
basic error handling
Diffstat (limited to 'translate-widget')
-rw-r--r--translate-widget/translate.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/translate-widget/translate.lua b/translate-widget/translate.lua
index 29d2295..e33053d 100644
--- a/translate-widget/translate.lua
+++ b/translate-widget/translate.lua
@@ -1,17 +1,19 @@
-------------------------------------------------
--- Translate Widget
+-- Translate Widget based on the Yandex.Translate API
+-- https://tech.yandex.com/translate/
-- @author Pavel Makhov
-- @copyright 2017 Pavel Makhov
-------------------------------------------------
-package.path = package.path .. ";../../secrets.lua"
+--package.path = package.path .. ";/home/streetturtle/.config/awesome/awesome-wm-widgets/secrets.lua"
local secrets = require("secrets")
local awful = require("awful")
local capi = {keygrabber = keygrabber }
local https = require("ssl.https")
local json = require("json")
+local naughty = require("naughty")
local wibox = require("wibox")
local API_KEY = secrets.translate_widget_api_key
@@ -27,6 +29,14 @@ local function extract(input_string)
if word ~= nill and lang ~= nill then
lang = lang:sub(1, 2) .. '-' .. lang:sub(3)
end
+ if lang == nil then
+ naughty.notify({
+ preset = naughty.config.presets.critical,
+ title = 'Translate Widget Error',
+ text = 'Language is not provided',
+ })
+ end
+
return word, lang
end
@@ -121,6 +131,12 @@ local function translate(request_string)
w.visible = false
end
end)
+ else
+ naughty.notify({
+ preset = naughty.config.presets.critical,
+ title = 'Translate Widget Error',
+ text = 'resp_json',
+ })
end
end