avoid showing ugly red error cards to users

This commit is contained in:
Vendicated 2025-06-06 18:48:56 +02:00
parent e7076f5aee
commit fae15dbdfe
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
11 changed files with 20 additions and 18 deletions

View file

@ -48,7 +48,7 @@ export function _modifyAccessories(
) {
for (const [key, accessory] of accessories.entries()) {
const res = (
<ErrorBoundary message={`Failed to render ${key} Message Accessory`} key={key}>
<ErrorBoundary noop message={`Failed to render ${key} Message Accessory`} key={key}>
<accessory.render {...props} />
</ErrorBoundary>
);

View file

@ -75,10 +75,15 @@ const ErrorBoundary = LazyComponent(() => {
logger.error(`${this.props.message || "A component threw an Error"}\n`, error, errorInfo.componentStack);
}
get isNoop() {
if (IS_DEV) return false;
return this.props.noop;
}
render() {
if (this.state.error === NO_ERROR) return this.props.children;
if (this.props.noop) return null;
if (this.isNoop) return null;
if (this.props.fallback)
return (

View file

@ -270,7 +270,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
{!!plugin.settingsAboutComponent && (
<div className={classes(Margins.bottom8, "vc-text-selectable")}>
<Forms.FormSection>
<ErrorBoundary message="An error occurred while rendering this plugin's custom InfoComponent">
<ErrorBoundary message="An error occurred while rendering this plugin's custom Info Component">
<plugin.settingsAboutComponent tempSettings={tempSettings} />
</ErrorBoundary>
</Forms.FormSection>

View file

@ -150,5 +150,5 @@ export default definePlugin({
}
},
DecorSection: ErrorBoundary.wrap(DecorSection)
DecorSection: ErrorBoundary.wrap(DecorSection, { noop: true })
});

View file

@ -118,7 +118,7 @@ export default definePlugin({
renderSearchBar(instance: Instance, SearchBarComponent: TSearchBarComponent) {
this.instance = instance;
return (
<ErrorBoundary noop={true}>
<ErrorBoundary noop>
<SearchBar instance={instance} SearchBarComponent={SearchBarComponent} />
</ErrorBoundary>
);

View file

@ -99,7 +99,7 @@ export default definePlugin({
src={`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${roleId}/${role.icon}.webp?size=24&quality=lossless`}
/>
);
}),
}, { noop: true }),
});
function getUsernameString(username: string) {

View file

@ -20,7 +20,6 @@ import { addMessageAccessory, removeMessageAccessory } from "@api/MessageAccesso
import { updateMessage } from "@api/MessageUpdater";
import { definePluginSettings } from "@api/Settings";
import { getUserSettingLazy } from "@api/UserSettings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants.js";
import { classes } from "@utils/misc";
import { Queue } from "@utils/Queue";
@ -373,7 +372,7 @@ export default definePlugin({
settings,
start() {
addMessageAccessory("messageLinkEmbed", props => {
addMessageAccessory("MessageLinkEmbeds", props => {
if (!messageLinkRegex.test(props.message.content))
return null;
@ -381,16 +380,14 @@ export default definePlugin({
messageLinkRegex.lastIndex = 0;
return (
<ErrorBoundary>
<MessageEmbedAccessory
message={props.message}
/>
</ErrorBoundary>
<MessageEmbedAccessory
message={props.message}
/>
);
}, 4 /* just above rich embeds */);
},
stop() {
removeMessageAccessory("messageLinkEmbed");
removeMessageAccessory("MessageLinkEmbeds");
}
});

View file

@ -204,5 +204,5 @@ export default definePlugin({
/>
</>
);
})
}, { noop: true })
});

View file

@ -75,5 +75,5 @@ export default definePlugin({
}}> Pause Indefinitely.</a>}
</div>
);
})
}, { noop: true })
});

View file

@ -86,5 +86,5 @@ export default definePlugin({
</TooltipContainer>
)}
</div>;
})
}, { noop: true })
});

View file

@ -125,7 +125,7 @@ function VencordPopoutButton() {
function ToolboxFragmentWrapper({ children }: { children: ReactNode[]; }) {
children.splice(
children.length - 1, 0,
<ErrorBoundary noop={true}>
<ErrorBoundary noop>
<VencordPopoutButton />
</ErrorBoundary>
);