Can plugin error messages be less verbose?

It’s not so much a question of “don’t like it” as “it does not achieve the desired result”.

Both error and error.message produces the undesired verbosity, but they’re slightly different.

error: AxiosError: Request failed with status code 404

error.message: Error: Request failed with status code 404

However, it occurred to me late last night that maybe I’m trying to suppress the verbosity the wrong way.

My initial thought was to suppress the verbosity that comes “from” the plugin error, by editing the code within the plugin, but it seems as if that verbosity is inserted by Bubble after receiving the error from the plugin.

And from a diagnostic perspective, that detail may be useful to someone at Bubble troubleshooting any issue that may be occurring.

I just don’t want my users to see it.

So… late last night it occurred to me that since the message I want to show is on a line all by itself, maybe I can use a RegularExpression to “filter in” only that one line.

And that worked.

So I put the catch code back to this:

        catch (error) {
            callback(error.message)
        }

Which produced this very verbose this:
image

Until I ran it though a RegEx on the front end, like this:

And now, what my users will see is:
image

So, I thank everyone for their input. I learned a few things.

But this turned out to be a case of there being more than one way to achieve a desired result.

Just to add another pattern that can give you more control:
instead of trowing the error and getting the long error generate by bubble, you can always return a value but you include 2 extra properties: errormessage and returnederror. It’s similar to what happens with the API connector when you check include errors. You never throw and handle failures in the workflow by checking returnederror, and errormessage is just a text for bubble so it will not add other logs to it.

example:

const [error, msg] = context.async(async (callback) => {
	try {
		const response = await axios.get("your url");
		callback(null, [null, response.statusText || "ok"]);
	} catch (error) {
		callback(null, [error, null]);
	}
});

const pluginResponse = {
	msg,
	errormessage: error?.message,
	returnederror: !!error,
};

return pluginResponse;

Interesting idea. Thank you.