Skip to content

Commit 7047091

Browse files
Handle errors when fetching Dockerfile template
1 parent 33e172a commit 7047091

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/commands/test.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ async function runDocker(datasource, opts) {
187187
} catch (error) {
188188
print.info('A problem occurred while reading matchstick.yaml. Please attend to the errors below:')
189189
print.error(error.message)
190-
return
190+
process.exit(1)
191191
}
192192
}
193193

@@ -252,17 +252,26 @@ async function runDocker(datasource, opts) {
252252
// Downloads Dockerfile template from the demo-subgraph repo
253253
// Replaces the placeholders with their respective values
254254
async function dockerfile(dockerfilePath, versionOpt, latestVersion) {
255-
let result = await fetch('https://raw.githubusercontent.com/LimeChain/demo-subgraph/main/Dockerfile')
256-
let content = await result.text()
255+
let content = await fetch('https://raw.githubusercontent.com/LimeChain/demo-subgraph/main/Dockerfile')
256+
.then((response) => {
257+
if (response.ok) {
258+
return response.text()
259+
} else {
260+
print.error('A problem occurred while downloading the Dockerfile template:')
261+
print.error(`Status Code: ${response.status}, with error: ${response.statusText}`)
262+
process.exit(1)
263+
}
264+
})
265+
257266

258267
// Create the Dockerfile
259268
try {
260269
await filesystem.write(dockerfilePath, content)
261270
print.info('Successfully generated Dockerfile.')
262271
} catch (error) {
263-
print.info('A problem occurred while generating the Dockerfile. Please attend to the errors below:')
272+
print.error('A problem occurred while generating the Dockerfile. Please attend to the errors below:')
264273
print.error(error.message)
265-
return
274+
process.exit(1)
266275
}
267276

268277
await patching.update(dockerfilePath, data => {

0 commit comments

Comments
 (0)