Skip to content

Commit

Permalink
Merge pull request #331 from wellcomecollection/fix/logging-create-sc…
Browse files Browse the repository at this point in the history
…ript

adding logging to create script
  • Loading branch information
melanierogan authored Jun 21, 2022
2 parents 1117bdb + f744224 commit 8d750db
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/apps/auth0-database-scripts/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const userAlreadyExistsMessage =
async function create(user: Auth0UserWithPassword) {
// We need to create the patron in sierra, we will update the patron info with firstName, lastName etc
// when we get this information from the full registration form
console.log('CREATE FUNCTION BEGINS');

const apiRoot = configuration.API_ROOT;
const clientKey = configuration.CLIENT_KEY;
Expand All @@ -34,9 +35,11 @@ async function create(user: Auth0UserWithPassword) {
user.password
);
if (createPatronResponse.status === ResponseStatus.UserAlreadyExists) {
console.log('CREATE PATRON IN SIERRA ERRORS - USER ALREADY EXISTS');
throw new ValidationError(user.email, userAlreadyExistsMessage);
}
if (createPatronResponse.status !== ResponseStatus.Success) {
console.log('CREATE PATRON IN SIERRA ERRORS');
throw new Error(createPatronResponse.message);
}

Expand All @@ -45,6 +48,7 @@ async function create(user: Auth0UserWithPassword) {
user.email
);
if (findPatronResponse.status !== ResponseStatus.Success) {
console.log('FIND PATRON BARCODE - NOT SUCCESSFUL');
throw new Error(findPatronResponse.message);
}
const { recordNumber } = findPatronResponse.result;
Expand All @@ -56,6 +60,7 @@ async function create(user: Auth0UserWithPassword) {
recordNumber.toString()
);
if (updatePatronBarcodeResponse.status !== ResponseStatus.Success) {
console.log('UPDATE PATRON BARCODE NOT SUCCESSFUL');
throw new Error(updatePatronBarcodeResponse.message);
}
}
Expand Down

0 comments on commit 8d750db

Please sign in to comment.