Skip to content

Commit

Permalink
Catch validation errors in kickOffEnd event #8
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-ignatov committed Dec 14, 2022
1 parent 7ef4741 commit 3f8d2e3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/lib/BulkDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,19 +379,19 @@ class BulkDataClient extends EventEmitter
})
}

const res = await this.request(requestOptions, "kick-off request")
.catch(error => {
return this.request(requestOptions, "kick-off request")
.then(res => {
const location = res.headers["content-location"];
if (!location) {
throw new Error("The kick-off response did not include content-location header")
}
this.emit("kickOffEnd", { response: res, capabilityStatement, requestParameters })
return location
})
.catch(error => {
this.emit("kickOffEnd", { response: error.response || {}, capabilityStatement, requestParameters })
throw error
});

const location = res.headers["content-location"];

assert(location, "The kick-off response did not include content-location header")

this.emit("kickOffEnd", { response: res, capabilityStatement, requestParameters })

return location
}

/**
Expand Down

0 comments on commit 3f8d2e3

Please sign in to comment.