mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 20:25:26 +00:00
Delegated model checks to getModelContents function;
Added try-catch to handle failure
This commit is contained in:
@@ -41,25 +41,14 @@ async function createPass(options: FactoryOptions) {
|
|||||||
// Voglio leggere i certificati
|
// Voglio leggere i certificati
|
||||||
// Voglio leggere il model (se non è un oggetto)
|
// Voglio leggere il model (se non è un oggetto)
|
||||||
|
|
||||||
/* Model checks */
|
try {
|
||||||
|
const [model, certificates] = await Promise.all([
|
||||||
if (!options.model) {
|
getModelContents(options.model),
|
||||||
throw new Error("Unable to create Pass: no model passed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof options.model !== "string" && typeof options.model !== "object") {
|
|
||||||
throw new Error("Unable to create Pass: unsupported type");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof options.model === "object" && !Object.keys(options.model).length) {
|
|
||||||
throw new Error("Unable to create Pass: object model has no content");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Certificates checks */
|
|
||||||
|
|
||||||
const { certificates } = await Promise.all([
|
|
||||||
readCertificatesFromOptions(options.certificates)
|
readCertificatesFromOptions(options.certificates)
|
||||||
]);
|
]);
|
||||||
|
} catch (err) {
|
||||||
|
// @TODO: analyze the error and stop the execution somehow
|
||||||
|
}
|
||||||
|
|
||||||
// Controllo se il model è un oggetto o una stringa
|
// Controllo se il model è un oggetto o una stringa
|
||||||
// Se è un oggetto passo avanti
|
// Se è un oggetto passo avanti
|
||||||
|
|||||||
Reference in New Issue
Block a user