3 ms·
I don't actually know what an intent flow is! I tried to Google around, but all I can seem to find are proprietary keyword mishmashes used for digital payment s
by chaorace 6y ago
I don't actually know what an intent flow is! I tried to Google around, but all I can seem to find are proprietary keyword mishmashes used for digital payment systems. I'm guessing you're talking about, like, intent in the context of a state machine? Set me straight here if I misunderstand.
I see the validity of what you're saying, but only in the context of insufficiently verbose third-party error messages. There's no reason that the exception message could not have been more detailed.
In my own projects, I like to design the functions that constitute the "plumbing" in such a way that they rethrow errors with more descriptive errors. We're venturing out into the realm of practice from that of theory, so this is just me sharing for the hell of it, but here's how that looks:
// Helper function meant to be reused in many function definitions
function throwIfFunctionParameterUndefined(functionName, parameterName, value){
if (value === undefined)
throw new TypeError(`${functionName} invoked with undefined parameter ${parameterName}`)
}
function doThing(paramA, paramB, optionalParam){
// Assert and throw for things we can guarantee in a meaningful way
// Since this is plumbing, we trust that higher level functions will catch if this is recoverable
const throwIfParameterUndefined = (paramName, value) => throwIfFunctionParameterUndefined('doThing', paramName, value)
throwIfParameterUndefined('paramA', paramA)
throwIfParameterUndefined('paramB', paramB)
// Rethrow errors from third party libraries
try {
thirdPartyThing()
} catch (err){
err.message = 'thirdPartyThing invoked by doThing failed with message:\n' + err.message
throw err
}
}
- q3k 6y ago> I don't actually know what an intent flow is! Sorry, I might've made that up :). What I meant is that stracktraces do not necessarily reflect the actual code path that the error was caused by (eg. with deferals to internal work queues), and even if they do, they tend to have terrible SNR (too much technicalities of how your code is structured, not enough information about the data that caused the error in the first place).