Skip to content

Commit

Permalink
refactor: Capture the link resource/shader packs error
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Dec 22, 2023
1 parent 9651a2d commit 1763fa7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion xmcl-runtime/resourcePack/InstanceResourcePacksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Inject, LauncherAppKey, PathResolver, kGameDataPath } from '~/app'
import { InstanceService } from '~/instance'
import { ResourceService } from '~/resource'
import { AbstractService, ExposeServiceKey, Lock } from '~/service'
import { AnyError } from '~/util/error'
import { LauncherApp } from '../app/LauncherApp'
import { linkWithTimeoutOrCopy } from '../util/fs'
import { tryLink } from '../util/linkResourceFolder'
Expand Down Expand Up @@ -54,7 +55,7 @@ export class InstanceResourcePackService extends AbstractService implements IIns
const isLinked = await tryLink(srcPath, destPath, this, (path) => this.instanceService.isUnderManaged(path))
return isLinked
} catch (e) {
this.error(e as Error)
this.error(new AnyError('LinkResourcePacksError', `Fail to link resourcepacks folder under: "${instancePath}"`, { cause: e }))
return false
}
}
Expand Down
5 changes: 3 additions & 2 deletions xmcl-runtime/shaderPack/InstanceShaderPacksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { InstanceShaderPacksService as IInstanceShaderPacksServic, InstanceShade
import { existsSync } from 'fs'
import { readdir } from 'fs/promises'
import { basename, join } from 'path'
import { LauncherAppKey, PathResolver, kGameDataPath, Inject } from '~/app'
import { Inject, LauncherAppKey, PathResolver, kGameDataPath } from '~/app'
import { InstanceService } from '~/instance'
import { ResourceService } from '~/resource'
import { AbstractService, ExposeServiceKey, Lock } from '~/service'
import { AnyError } from '~/util/error'
import { LauncherApp } from '../app/LauncherApp'
import { linkWithTimeoutOrCopy } from '../util/fs'
import { tryLink } from '../util/linkResourceFolder'
Expand Down Expand Up @@ -54,7 +55,7 @@ export class InstanceShaderPacksService extends AbstractService implements IInst
const isLinked = await tryLink(srcPath, destPath, this, (path) => this.instanceService.isUnderManaged(path))
return isLinked
} catch (e) {
this.error(e as Error)
this.error(new AnyError('LinkShaderPacksError', `Fail to link shaderpacks folder under: "${instancePath}"`, { cause: e }))
return false
}
}
Expand Down

0 comments on commit 1763fa7

Please sign in to comment.