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
6d874dd1
Commit
6d874dd1
authored
Feb 05, 2019
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved error handling
parent
da531032
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
+24
-9
public/app/core/copy/appNotification.ts
+20
-6
public/app/features/dashboard/state/initDashboard.ts
+4
-3
No files found.
public/app/core/copy/appNotification.ts
View file @
6d874dd1
import
_
from
'lodash'
;
import
{
AppNotification
,
AppNotificationSeverity
,
AppNotificationTimeout
}
from
'app/types'
;
const
defaultSuccessNotification
:
AppNotification
=
{
...
...
@@ -31,12 +32,25 @@ export const createSuccessNotification = (title: string, text?: string): AppNoti
id
:
Date
.
now
(),
});
export
const
createErrorNotification
=
(
title
:
string
,
text
?:
string
):
AppNotification
=>
({
...
defaultErrorNotification
,
title
:
title
,
text
:
text
,
id
:
Date
.
now
(),
});
export
const
createErrorNotification
=
(
title
:
string
,
text
?:
any
):
AppNotification
=>
{
// Handling if text is an error object
if
(
text
&&
!
_
.
isString
(
text
))
{
if
(
text
.
message
)
{
text
=
text
.
message
;
}
else
if
(
text
.
data
&&
text
.
data
.
message
)
{
text
=
text
.
data
.
message
;
}
else
{
text
=
text
.
toString
();
}
}
return
{
...
defaultErrorNotification
,
title
:
title
,
text
:
text
,
id
:
Date
.
now
(),
};
};
export
const
createWarningNotification
=
(
title
:
string
,
text
?:
string
):
AppNotification
=>
({
...
defaultWarningNotification
,
...
...
public/app/features/dashboard/state/initDashboard.ts
View file @
6d874dd1
...
...
@@ -81,7 +81,6 @@ export function initDashboard({
try
{
switch
(
routeInfo
)
{
// handle old urls with no uid
case
DashboardRouteInfo
.
Home
:
{
// load home dash
dashDTO
=
await
getBackendSrv
().
get
(
'/api/dashboards/home'
);
...
...
@@ -130,6 +129,7 @@ export function initDashboard({
}
}
catch
(
err
)
{
dispatch
(
setDashboardLoadingState
(
DashboardLoadingState
.
Error
));
dispatch
(
notifyApp
(
createErrorNotification
(
'Dashboard fetch failed'
,
err
)));
console
.
log
(
err
);
return
;
}
...
...
@@ -143,6 +143,7 @@ export function initDashboard({
dashboard
=
new
DashboardModel
(
dashDTO
.
dashboard
,
dashDTO
.
meta
);
}
catch
(
err
)
{
dispatch
(
setDashboardLoadingState
(
DashboardLoadingState
.
Error
));
dispatch
(
notifyApp
(
createErrorNotification
(
'Dashboard model initializing failure'
,
err
)));
console
.
log
(
err
);
return
;
}
...
...
@@ -168,7 +169,7 @@ export function initDashboard({
try
{
await
variableSrv
.
init
(
dashboard
);
}
catch
(
err
)
{
dispatch
(
notifyApp
(
createErrorNotification
(
'Templating init failed'
)));
dispatch
(
notifyApp
(
createErrorNotification
(
'Templating init failed'
,
err
)));
console
.
log
(
err
);
}
...
...
@@ -194,7 +195,7 @@ export function initDashboard({
keybindingSrv
.
setupDashboardBindings
(
$scope
,
dashboard
,
onRemovePanel
);
}
catch
(
err
)
{
dispatch
(
notifyApp
(
createErrorNotification
(
'Dashboard init failed'
,
err
.
toString
()
)));
dispatch
(
notifyApp
(
createErrorNotification
(
'Dashboard init failed'
,
err
)));
console
.
log
(
err
);
}
...
...
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