_mercury – 20-47 Jul 20

when try {} actually work in Js?
12 Replies
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
ghardin137
ghardin137β€’3y ago
when your code inside it throws an error?
_mercury πŸ‡΅πŸ‡Έ
js error ? or db error ?
ghardin137
ghardin137β€’3y ago
js error
_mercury πŸ‡΅πŸ‡Έ
or pasrseInt? parseInt error?
ghardin137
ghardin137β€’3y ago
parseInt probably won't throw an error it'll just return isNaN
_mercury πŸ‡΅πŸ‡Έ
not good Like
const groups = await pool.query(
`
select g.* from groups g
left join attribute_groups ag on g.id = ag.group_id
left join attributes a on a.id = ag.attribute_id
where a.id = ?
`,
[attribute.id]
);
const groups = await pool.query(
`
select g.* from groups g
left join attribute_groups ag on g.id = ag.group_id
left join attributes a on a.id = ag.attribute_id
where a.id = ?
`,
[attribute.id]
);
how to make this code throw an error if there is no DB success
ghardin137
ghardin137β€’3y ago
when you say db success what do you mean?
_mercury πŸ‡΅πŸ‡Έ
I mean get valid results Actual rows not empty result [] or {}
ghardin137
ghardin137β€’3y ago
that's not an error that's just there's nothing that matches it's a valid end state so you'd just need to check if that's the value yourself
_mercury πŸ‡΅πŸ‡Έ
Ok thx
reactibot
reactibotβ€’3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/999417183635525773