fix: don't wrap functions twice in entrypoint
This commit is contained in:
parent
24c4985ae8
commit
2f21be2c52
1 changed files with 21 additions and 21 deletions
42
src/index.ts
42
src/index.ts
|
|
@ -18,7 +18,7 @@ import { getErrorStack } from '@revenge-mod/utils/errors'
|
|||
const IndexModuleId = 0
|
||||
|
||||
onModuleFirstRequired(IndexModuleId, function onIndexRequired() {
|
||||
runCatching(() => {
|
||||
try {
|
||||
if (__BUILD_FLAG_LOG_PROMISE_REJECTIONS__)
|
||||
require('./patches/log-promise-rejections')
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() {
|
|||
require('@revenge-mod/plugins/preinit')
|
||||
|
||||
onModuleInitialized(IndexModuleId, function onIndexInitialized() {
|
||||
runCatching(() => {
|
||||
try {
|
||||
// Initialize init libraries
|
||||
require('@revenge-mod/storage/init')
|
||||
require('@revenge-mod/externals/init')
|
||||
|
|
@ -44,28 +44,28 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() {
|
|||
// Run all init plugins
|
||||
require('~/plugins/init')
|
||||
require('@revenge-mod/plugins/init')
|
||||
})
|
||||
} catch (e) {
|
||||
onError(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
} catch (e) {
|
||||
onError(e)
|
||||
}
|
||||
})
|
||||
|
||||
function runCatching(fn: () => void) {
|
||||
try {
|
||||
fn()
|
||||
} catch (e) {
|
||||
// TODO(init): Move to use native provided alert function, which will accept a string stack trace
|
||||
// Above will reduce the need for runCatching() to exist, as the code won't be able to be deduped any further
|
||||
const { ClientInfoModule, DeviceModule } =
|
||||
require('@revenge-mod/discord/native') as typeof import('@revenge-mod/discord/native')
|
||||
function onError(e: unknown) {
|
||||
// TODO(init): Move to use native provided alert function, which will accept a string stack trace
|
||||
// Above will reduce the need for runCatching() to exist, as the code won't be able to be deduped any further
|
||||
const { ClientInfoModule, DeviceModule } =
|
||||
require('@revenge-mod/discord/native') as typeof import('@revenge-mod/discord/native')
|
||||
|
||||
const Client = ClientInfoModule.getConstants()
|
||||
const Device = DeviceModule.getConstants()
|
||||
const Client = ClientInfoModule.getConstants()
|
||||
const Device = DeviceModule.getConstants()
|
||||
|
||||
alert(
|
||||
`Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` +
|
||||
`Discord: ${Client.Version} (${Client.Build})\n` +
|
||||
`Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` +
|
||||
getErrorStack(e),
|
||||
)
|
||||
}
|
||||
alert(
|
||||
`Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` +
|
||||
`Discord: ${Client.Version} (${Client.Build})\n` +
|
||||
`Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` +
|
||||
getErrorStack(e),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue