Improve error message
This commit is contained in:
parent
7fe599c8f9
commit
b3d204b128
|
@ -72,11 +72,13 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
console.log('user current invested amount', currentInvested)
|
console.log('user current invested amount', currentInvested)
|
||||||
console.log('mana limit:', manaLimitPerUser)
|
console.log('mana limit:', manaLimitPerUser)
|
||||||
|
|
||||||
if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser)
|
if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser) {
|
||||||
|
const manaAllowed = manaLimitPerUser - currentInvested
|
||||||
return {
|
return {
|
||||||
status: 'error',
|
status: 'error',
|
||||||
message: `Market investment limit is M$${manaLimitPerUser}, you've M$${currentInvested} already`,
|
message: `Market bet cap is M$${manaLimitPerUser}, M$${manaAllowed} left`,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const [lastAnswer] = await getValues<Answer>(
|
const [lastAnswer] = await getValues<Answer>(
|
||||||
firestore
|
firestore
|
||||||
.collection(`contracts/${contractId}/answers`)
|
.collection(`contracts/${contractId}/answers`)
|
||||||
|
|
|
@ -82,11 +82,13 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
console.log('user current invested amount', currentInvested)
|
console.log('user current invested amount', currentInvested)
|
||||||
console.log('mana limit:', manaLimitPerUser)
|
console.log('mana limit:', manaLimitPerUser)
|
||||||
|
|
||||||
if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser)
|
if (manaLimitPerUser && currentInvested + amount > manaLimitPerUser) {
|
||||||
|
const manaAllowed = manaLimitPerUser - currentInvested
|
||||||
return {
|
return {
|
||||||
status: 'error',
|
status: 'error',
|
||||||
message: `Market investment limit is M$${manaLimitPerUser}, you've M$${currentInvested} already`,
|
message: `Market bet cap is M$${manaLimitPerUser}, M$${manaAllowed} left`,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBetDoc = firestore
|
const newBetDoc = firestore
|
||||||
|
|
Loading…
Reference in New Issue
Block a user