mirror of
https://github.com/tobspr-games/shapez.io.git
synced 2026-02-06 07:41:46 -08:00
* Migrate Electron wrapper to ESM Use ESM syntax for main process, move some fs usages to fs.promises, switch to import.meta.url/import.meta.dirname to handle file paths; clean up redundant code. * Add TypeScript support to Electron wrapper The support is very basic, tsc is used to transpile code. Build scripts are modified to not copy any Electron code other than preload.cjs and use an extremely cursed setup to call the TypeScript compiler. * [TS] Rename platform/storage * Rewrite Electron wrapper MVP, missing some features from the old wrapper and most planned features. Some of the functionality hasn't been verified.
23 lines
704 B
TypeScript
23 lines
704 B
TypeScript
/**
|
|
* Represents a filesystem error as reported by the main process.
|
|
*/
|
|
export class FsError extends Error {
|
|
code?: string;
|
|
|
|
constructor(message?: string, options?: ErrorOptions) {
|
|
super(message, options);
|
|
Error.captureStackTrace(this, FsError);
|
|
this.name = "FsError";
|
|
|
|
// Take the code from the error message, quite ugly
|
|
if (options?.cause && options.cause instanceof Error) {
|
|
// Example message:
|
|
// Error invoking remote method 'fs-job': Error: ENOENT: no such...
|
|
this.code = options.cause.message.split(":")[2].trim();
|
|
}
|
|
}
|
|
|
|
isFileNotFound(): boolean {
|
|
return this.code === "ENOENT";
|
|
}
|
|
}
|