-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy patherror.js
More file actions
41 lines (34 loc) · 1.43 KB
/
error.js
File metadata and controls
41 lines (34 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// ----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// ----------------------------------------------------------------------------
// Show error to the user
function showError(err) {
let errorContainer = $("#error-container");
globals.reportWrapper.hide();
globals.dashboardWrapper.hide();
globals.tileWrapper.hide();
$(".config-container").hide();
$("header").hide();
// Show error container
errorContainer.show();
// Format error message
let errHeader = document.createTextNode("Error Details:");
let strong = document.createElement("strong");
strong.appendChild(errHeader);
// Create paragraph element to store error header and error message
let errorMessage = document.createElement("p");
errorMessage.appendChild(strong);
// Break error message around \n and appends break element at the corresponding index
let arr = err.responseText.split("\n");
for (let i = 0; i < arr.length; i++) {
let br = document.createElement("br");
// Create node element to store individual line from the error message
// along with the break element
let node = document.createTextNode(arr[i]);
errorMessage.appendChild(br);
errorMessage.appendChild(node);
}
// Show error message on UI
errorContainer.get(0).appendChild(errorMessage);
}