Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Restructure error messages as ErrorDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
Diane Huxley committed Nov 12, 2023
1 parent 0cb99d5 commit 879cf1e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/http-server/src/request-handlers/submit-rfq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function submitRfq(options: SubmitRfqOpts): RequestHandler {
try {
message = await Message.parse(req.body)
} catch(e) {
const errorResponse: ErrorDetail = { detail: e.message }
const errorResponse: ErrorDetail = { detail: `Parsing of TBDex message failed: ${e.message}` }
return res.status(400).json({ errors: [errorResponse] })
}

Expand All @@ -31,12 +31,14 @@ export function submitRfq(options: SubmitRfqOpts): RequestHandler {

const rfqExists = !! await exchangesApi.getRfq({ exchangeId: message.id })
if (rfqExists) {
return res.status(409).json({ errors: [`rfq ${message.id} already exists`] })
const errorResponse: ErrorDetail = { detail: `rfq ${message.id} already exists`}
return res.status(409).json({ errors: [errorResponse] })
}

const offering = await offeringsApi.getOffering({ id: message.data.offeringId })
if (!offering) {
return res.status(400).json({ errors: [`offering ${message.data.offeringId} does not exist`] })
const errorResponse: ErrorDetail = { detail: `offering ${message.data.offeringId} does not exist` }
return res.status(400).json({ errors: [errorResponse] })
}

try {
Expand Down

0 comments on commit 879cf1e

Please sign in to comment.