Skip to content

Commit

Permalink
handle exception for httpGetInitialState() gracefully. (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jing T authored Jan 19, 2023
1 parent fc81078 commit 395f7e7
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src-electron/rest/user-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,20 +330,24 @@ function httpPostEventUpdate(db) {
function httpGetInitialState(db) {
return async (request, response) => {
let sessionId = request.zapSessionId
let state = {}
let state = { endpointTypes: [], endpoints: [], sessionKeyValues: [] }

let session = await querySession.getSessionFromSessionId(db, sessionId)
asyncValidation.initAsyncValidation(db, session)

let results = await Promise.all([
queryEndpointType.selectAllEndpointTypes(db, sessionId),
queryEndpoint.selectAllEndpoints(db, sessionId),
querySession.getAllSessionKeyValues(db, sessionId),
])

state.endpointTypes = results[0]
state.endpoints = results[1]
state.sessionKeyValues = results[2]
try {
let session = await querySession.getSessionFromSessionId(db, sessionId)
await asyncValidation.initAsyncValidation(db, session)

let results = await Promise.all([
queryEndpointType.selectAllEndpointTypes(db, sessionId),
queryEndpoint.selectAllEndpoints(db, sessionId),
querySession.getAllSessionKeyValues(db, sessionId),
])

state.endpointTypes = results[0]
state.endpoints = results[1]
state.sessionKeyValues = results[2]
} catch (error) {
console.error(error)
}

response.status(StatusCodes.OK).json(state)
}
Expand Down

0 comments on commit 395f7e7

Please sign in to comment.