Handle catching unknowns

This commit is contained in:
Misode
2021-09-09 22:34:22 +02:00
parent fd503f1d03
commit e3fb5923c0
4 changed files with 20 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ import * as java16 from '@mcschema/java-1.16'
import * as java17 from '@mcschema/java-1.17'
import config from '../config.json'
import { fetchData } from './DataFetcher'
import { message } from './Utils'
export const VersionIds = ['1.15', '1.16', '1.17'] as const
export type VersionId = typeof VersionIds[number]
@@ -55,7 +56,7 @@ async function getVersion(id: VersionId): Promise<VersionData> {
Versions[id] = { collections, schemas, blockStates }
return Versions[id]
} catch (e) {
throw new Error(`Cannot get version "${id}": ${e.message}`)
throw new Error(`Cannot get version "${id}": ${message(e)}`)
}
})()
return Versions[id]
@@ -81,7 +82,7 @@ export async function getModel(version: VersionId, id: string): Promise<DataMode
}
Models[id] = { model, version }
} catch (e) {
throw new Error(`Cannot get generator "${id}" for version "${version}": ${e.message}`)
throw new Error(`Cannot get generator "${id}" for version "${version}": ${message(e)}`)
}
}
return Models[id].model