Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding logging to create script #331

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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