I’ve written a plugin that outputs a list of links for a specified URL.
This question is about error handling.
When I enter a URL that generates a 404 error, I get a very verbose error message.
I know from experimentation that axios (the node module I’m using to get the URL) generates only a tiny bit of it.
So the rest must be generated by Bubble.
My question is, is there anyway to suppress the verbosity and ONLY capture the value of error.message when axios.get(url) throws an error?
Specifically, in the verbose message below:
Plugin action getLinks error:
AxiosError: Request failed with status code 404
at settle (/var/task/node_modules/axios/dist/node/axios.cjs:1859:12)
at Unzip.handleStreamEnd (/var/task/node_modules/axios/dist/node/axios.cjs:2723:11)
at Unzip.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1333:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Error: Outer Error (see above for inner error)
at Block.wait (/var/task/u.js:467:22)
at Object.async_fn [as async] (/var/task/index.js:474:29)
at eval (eval at build_function (/var/task/index.js:53:12), :33:34)
at /var/task/index.js:527:17
at run_fn (/var/task/u.js:645:18)
The part returned in error.message is “Request failed with status code 404”.
That’s the only bit I want to be displayed in the error popup shown to the user.
Does anyone know if this can be done? And if so, how?
you may use the other error properties if it’s more convenient for you.
Or you can add logic to analyse the error and return your custom error with the callback.
And it returned the test custom error message, among all the verbosity.
I have no idea if I can throw an error in the catch section of the code, but I’ll run an experiment. It feels to me right now that that will be too late to suppress the verbosity, but we’ll see.
have you tried calling the callback with the whole error instead of the message? This way you should have other properties of the error available in the editor. As I said message is just one property
again: why are you still using error.messageif you don’t like it?
There is a clear example at the axios’ docs about handling errors. No nested try/catch needed, every error is handled, other properties of the error are used to give more context.
Of course you need to replace log statements with callback calls.