feature/23-voice-room/poc #93
@@ -47,6 +47,7 @@
|
||||
try {
|
||||
await joinVoiceRoom(url, h, joinAbortController.signal)
|
||||
} catch (e) {
|
||||
console.error("Failed to join voice room", e)
|
||||
pushToast({theme: "error", message: "Failed to join voice room"})
|
||||
|
hodlbod marked this conversation as resolved
Outdated
|
||||
} finally {
|
||||
isJoining = false
|
||||
|
||||
Reference in New Issue
Block a user
Why do the bots do this? I have seen this cause bugs more than once. Just do
e.message || String(e). Or, better yet, actually design the error types and don't put anything that gets thrown in a message to the user. Just tell them "Failed to join voice room" and log it if it's not an error we know what to do with.I am cleaning this up but I want to fully understand you. Can you explain how this causes bugs? As a non-javascript guy this doesn't look pretty but makes sense to me because
ecould literally be any type and there is no way to write a catch block for a specific type, so it seems reasonably defensive to check the type before just grabbing themessageproperty off of whatever might have been thrown. Or in the case where some library throws a String it seems reasonable to surface that.I understand the current code risks showing raw error messages to the user (which doesn't bother me actually as long as it has a nice prefix like "Failed to join voice room"). Is there something worse that I am missing?
Idk maybe it is stupid to think that some library would throw some random object with a
messageproperty, but anything seems possible whennode_modulesare involved 😓Oh interesting,
e.message || String(e)actually gives a typescript error:'e' is of type 'unknown'.. But AI found theerrorMessage()function from@lib/utilso I'll use that.The problem is when a pojo with a message gets thrown or rejected, which means the object gets cast to a string, which fails to show the message. This is the case when you probably actually want to show the message to the user, whereas showing an error's message is almost always confusing. Errors being completely untyped are a huge flaw in typescript, so I like to save throws for truly exceptional cases (https://effect.website/ does this more formally, and I think it's a good idea), in which case you want to log and recover if you can, and resolve/return everything else (even errors that are deferred to the caller). But I'm certainly not consistent about this.
errorMessagewas introduced by an LLM too (via Tyson), I don't really believe in it either. I think we should just avoid propagating thrown errors to the user (I don't like the "Failed to do x: [technical jargon]" pattern. It helps to debug some, but not really in that many cases.