Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
6e65c932
Commit
6e65c932
authored
Oct 21, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cli): improve error handling
parent
2c7dbde0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
pkg/cmd/grafana-cli/services/services.go
+11
-7
No files found.
pkg/cmd/grafana-cli/services/services.go
View file @
6e65c932
...
...
@@ -35,11 +35,11 @@ func Init(version string) {
}
func
ListAllPlugins
(
repoUrl
string
)
(
m
.
PluginRepo
,
error
)
{
body
,
err
:=
create
Request
(
repoUrl
,
"repo"
)
body
,
err
:=
send
Request
(
repoUrl
,
"repo"
)
if
err
!=
nil
{
logger
.
Info
(
"Failed to
create
request"
,
"error"
,
err
)
return
m
.
PluginRepo
{},
fmt
.
Errorf
(
"Failed to
create
request. error: %v"
,
err
)
logger
.
Info
(
"Failed to
send
request"
,
"error"
,
err
)
return
m
.
PluginRepo
{},
fmt
.
Errorf
(
"Failed to
send
request. error: %v"
,
err
)
}
if
err
!=
nil
{
...
...
@@ -112,11 +112,11 @@ func RemoveInstalledPlugin(pluginPath, pluginName string) error {
}
func
GetPlugin
(
pluginId
,
repoUrl
string
)
(
m
.
Plugin
,
error
)
{
body
,
err
:=
create
Request
(
repoUrl
,
"repo"
,
pluginId
)
body
,
err
:=
send
Request
(
repoUrl
,
"repo"
,
pluginId
)
if
err
!=
nil
{
logger
.
Info
(
"Failed to
create
request"
,
"error"
,
err
)
return
m
.
Plugin
{},
fmt
.
Errorf
(
"Failed to
create
request. error: %v"
,
err
)
logger
.
Info
(
"Failed to
send
request"
,
"error"
,
err
)
return
m
.
Plugin
{},
fmt
.
Errorf
(
"Failed to
send
request. error: %v"
,
err
)
}
if
err
!=
nil
{
...
...
@@ -133,7 +133,7 @@ func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) {
return
data
,
nil
}
func
create
Request
(
repoUrl
string
,
subPaths
...
string
)
([]
byte
,
error
)
{
func
send
Request
(
repoUrl
string
,
subPaths
...
string
)
([]
byte
,
error
)
{
u
,
_
:=
url
.
Parse
(
repoUrl
)
for
_
,
v
:=
range
subPaths
{
u
.
Path
=
path
.
Join
(
u
.
Path
,
v
)
...
...
@@ -149,6 +149,10 @@ func createRequest(repoUrl string, subPaths ...string) ([]byte, error) {
}
res
,
err
:=
HttpClient
.
Do
(
req
)
if
err
!=
nil
{
return
[]
byte
{},
err
}
if
res
.
StatusCode
/
100
!=
2
{
return
[]
byte
{},
fmt
.
Errorf
(
"Api returned invalid status: %s"
,
res
.
Status
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment