Skip to content

Commit a9402aa

Browse files
committed
error message
1 parent 0ec2c9a commit a9402aa

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

data.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,28 @@ const options = {
6060
};
6161

6262
(async function () {
63-
const result = await loadClientConfig();
63+
try {
64+
const result = await loadClientConfig();
6465

65-
const ctx = document.getElementById("data");
66+
const ctx = document.getElementById("data");
6667

67-
new Chart(ctx, {
68-
type: "line",
69-
options: options,
70-
data: {
71-
labels: result.map((item) => item.labels),
72-
datasets: [
73-
{
74-
data: result.map((item) => item.data)
75-
}
76-
]
77-
}
78-
});
68+
new Chart(ctx, {
69+
type: "line",
70+
options: options,
71+
data: {
72+
labels: result.map((item) => item.labels),
73+
datasets: [
74+
{
75+
data: result.map((item) => item.data)
76+
}
77+
]
78+
}
79+
});
80+
} catch {
81+
const body = document.querySelector("body");
82+
const message = document.createElement("p");
83+
message.classList.add("error");
84+
message.innerHTML = "Please run this page in a formsort flow.";
85+
body.prepend(message);
86+
}
7987
})();

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="stylesheet" href="./styles.css" />
67
<title>Chart.js</title>
78
</head>
89
<body>

styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
p.error {
2+
color: red;
3+
font-size: 1.5em;
4+
text-align: center;
5+
}

0 commit comments

Comments
 (0)