Skip to content

Commit e6ea711

Browse files
committed
Adds error handling to configuration request
Catch request exception in case fetching the configuration from the url fails, this can happen either if non existent version number is passed in or because of server issues.
1 parent 6173105 commit e6ea711

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

docs/index.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,20 @@
100100
if (this.version !== this.oldVersion) {
101101
const ConfigurationMdUrl =
102102
`https://raw.githubusercontent.com/rust-lang/rustfmt/${this.version}/Configurations.md`;
103-
const res = await axios.get(ConfigurationMdUrl);
104-
const {
105-
about,
106-
configurationAbout,
107-
configurationDescriptions
108-
} = parseMarkdownAst(res.data);
109-
this.aboutHtml = marked.parser(about);
110-
this.configurationAboutHtml = marked.parser(configurationAbout);
111-
this.configurationDescriptions = configurationDescriptions;
112-
this.oldVersion = this.version;
103+
try {
104+
const res = await axios.get(ConfigurationMdUrl);
105+
const {
106+
about,
107+
configurationAbout,
108+
configurationDescriptions
109+
} = parseMarkdownAst(res.data);
110+
this.aboutHtml = marked.parser(about);
111+
this.configurationAboutHtml = marked.parser(configurationAbout);
112+
this.configurationDescriptions = configurationDescriptions;
113+
this.oldVersion = this.version;
114+
} catch(error) {
115+
this.aboutHtml = "<p>Failed to get configuration options for this version, please select the version from the dropdown above.</p>";
116+
}
113117
}
114118

115119
const ast = this.configurationDescriptions

0 commit comments

Comments
 (0)