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
a56c5841
Commit
a56c5841
authored
Oct 11, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: improve error handling in the datasource
parent
afe0b4b8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
public/app/plugins/datasource/stackdriver/datasource.ts
+12
-21
No files found.
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
a56c5841
...
...
@@ -198,6 +198,14 @@ export default class StackdriverDatasource {
title
:
'Success'
,
};
}
catch
(
error
)
{
return
{
status
:
'error'
,
message
:
this
.
formatStackdriverError
(
error
),
};
}
}
formatStackdriverError
(
error
)
{
let
message
=
'Stackdriver: '
;
message
+=
error
.
statusText
?
error
.
statusText
+
': '
:
''
;
if
(
error
.
data
&&
error
.
data
.
error
)
{
...
...
@@ -210,11 +218,7 @@ export default class StackdriverDatasource {
}
else
{
message
+=
'Cannot connect to Stackdriver API'
;
}
return
{
status
:
'error'
,
message
:
message
,
};
}
return
message
;
}
async
getDefaultProject
()
{
...
...
@@ -239,21 +243,7 @@ export default class StackdriverDatasource {
return
this
.
projectName
;
}
}
catch
(
error
)
{
let
message
=
'Projects cannot be fetched: '
;
message
+=
error
.
statusText
?
error
.
statusText
+
': '
:
''
;
if
(
error
&&
error
.
data
&&
error
.
data
.
error
&&
error
.
data
.
error
.
message
)
{
if
(
error
.
data
.
error
.
code
===
403
)
{
message
+=
`
A list of projects could not be fetched from the Google Cloud Resource Manager API.
You might need to enable it first:
https://console.developers.google.com/apis/library/cloudresourcemanager.googleapis.com`
;
}
else
{
message
+=
error
.
data
.
error
.
code
+
'. '
+
error
.
data
.
error
.
message
;
}
}
else
{
message
+=
'Cannot connect to Stackdriver API'
;
}
appEvents
.
emit
(
'ds-request-error'
,
message
);
appEvents
.
emit
(
'ds-request-error'
,
this
.
formatStackdriverError
(
error
));
return
''
;
}
}
...
...
@@ -274,7 +264,8 @@ export default class StackdriverDatasource {
return
metrics
;
}
catch
(
error
)
{
console
.
log
(
error
);
appEvents
.
emit
(
'ds-request-error'
,
this
.
formatStackdriverError
(
error
));
return
[];
}
}
...
...
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