mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feature-274] handle irrelevant oculus download errors
Ignore errors such as "no token" when auto download or "window closed by user" in the ui
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
export enum OculusDownloaderErrorCodes {
|
||||
DOWNLOAD_MANIFEST_ZIP_FAILED = "DOWNLOAD_MANIFEST_ZIP_FAILED",
|
||||
MANIFEST_FILE_NOT_FOUND = "MANIFEST_FILE_NOT_FOUND",
|
||||
PARSE_MANIFEST_FILE_FAILED = "PARSE_MANIFEST_FILE_FAILED",
|
||||
ALREADY_DOWNLOADING = "ALREADY_DOWNLOADING",
|
||||
UNABLE_TO_GET_MANIFEST = "UNABLE_TO_GET_MANIFEST",
|
||||
VERIFY_INTEGRITY_FAILED = "VERIFY_INTEGRITY_FAILED",
|
||||
SOME_FILES_FAILED_TO_DOWNLOAD = "SOME_FILES_FAILED_TO_DOWNLOAD",
|
||||
}
|
||||
|
||||
export enum MetaAuthErrorCodes {
|
||||
OCULUS_LOGIN_TIMED_OUT = "OCULUS_LOGIN_TIMED_OUT",
|
||||
OCULUS_LOGIN_WINDOW_CLOSED_BY_USER = "OCULUS_LOGIN_WINDOW_CLOSED_BY_USER",
|
||||
NO_META_AUTH_TOKEN = "NO_META_AUTH_TOKEN",
|
||||
}
|
||||
@@ -12,14 +12,25 @@ export class CustomError extends Error {
|
||||
public get code(): string { return this._code; }
|
||||
public get data(): unknown { return this._data; }
|
||||
|
||||
public static fromError(error: Error, code: string, data?: unknown): CustomError{
|
||||
public static fromError(error: Error, code?: string, data?: unknown): CustomError{
|
||||
|
||||
if(error instanceof CustomError){
|
||||
return error;
|
||||
}
|
||||
|
||||
code ||= (error as unknown as {code: string}).code || CustomErrorCodes.UNKNOWN_ERROR;
|
||||
|
||||
const customError = new CustomError(error.message ?? error.toString(), code, data);
|
||||
customError.stack = error.stack;
|
||||
return customError;
|
||||
}
|
||||
|
||||
public static throw(error: Error, code: string, data?: unknown): never{
|
||||
public static throw(error: Error, code?: string, data?: unknown): never{
|
||||
throw CustomError.fromError(error, code, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export enum CustomErrorCodes {
|
||||
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
||||
}
|
||||
Reference in New Issue
Block a user