mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 00:37:49 +00:00
error boundary now properly reports steam errors
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { ErrorInfo } from 'react';
|
||||
|
||||
const pluginErrorRegex = /http:\/\/localhost:1337\/plugins\/([^\/]*)\//;
|
||||
const pluginSourceMapErrorRegex = /decky:\/\/decky\/plugin\/([^\/]*)\//;
|
||||
const legacyPluginErrorRegex = /decky:\/\/decky\/legacy_plugin\/([^\/]*)\/index.js/;
|
||||
|
||||
export interface ValveReactErrorInfo {
|
||||
error: Error;
|
||||
info: ErrorInfo;
|
||||
}
|
||||
|
||||
export interface ValveError {
|
||||
identifier: string;
|
||||
identifierHash: string;
|
||||
message: string | [func: string, src: string, line: number, column: number];
|
||||
}
|
||||
|
||||
export type ErrorSource = [source: string, wasPlugin: boolean, shouldReportToValve: boolean];
|
||||
|
||||
export function getLikelyErrorSourceFromValveError(error: ValveError): ErrorSource {
|
||||
return getLikelyErrorSource(JSON.stringify(error?.message));
|
||||
}
|
||||
|
||||
export function getLikelyErrorSourceFromValveReactError(error: ValveReactErrorInfo): ErrorSource {
|
||||
return getLikelyErrorSource(error?.error?.stack);
|
||||
}
|
||||
|
||||
export function getLikelyErrorSource(error?: string): ErrorSource {
|
||||
const pluginMatch = error?.match(pluginErrorRegex);
|
||||
if (pluginMatch) {
|
||||
return [decodeURIComponent(pluginMatch[1]), true, false];
|
||||
}
|
||||
|
||||
const pluginMatchViaMap = error?.match(pluginSourceMapErrorRegex);
|
||||
if (pluginMatchViaMap) {
|
||||
return [decodeURIComponent(pluginMatchViaMap[1]), true, false];
|
||||
}
|
||||
|
||||
const legacyPluginMatch = error?.match(legacyPluginErrorRegex);
|
||||
if (legacyPluginMatch) {
|
||||
return [decodeURIComponent(legacyPluginMatch[1]), true, false];
|
||||
}
|
||||
|
||||
if (error?.includes('http://localhost:1337/')) {
|
||||
return ['the Decky frontend', false, false];
|
||||
}
|
||||
return ['Steam', false, true];
|
||||
}
|
||||
Reference in New Issue
Block a user