Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 018dc17

Browse files
committed
Return error to user on email submission
Use a JavaScript alert to return an error conspicuously to students if something isn't properly setup with their DynamoDB table or Cognito identity pool. - Add common errors with resolution steps
1 parent 6740f13 commit 018dc17

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,26 @@ Visitors to your website who are interested in participating in your beta progra
303303

304304
![Confirmation](images/lab1_confirmation.png)
305305

306+
If something went wrong you will receive an error as a JavaScript alert. Open your developer console (see **Tips** section for insturctions) for more information.
307+
308+
Common errors are:
309+
310+
- __ResourceNotFoundException: Missing credentials in config__
311+
312+
Your _config.js_ does not map to a valid Cognito identity pool. Ensure that you've entered the **identityPoolId** correctly by checking your work in steps 37 through 40.
313+
314+
- __ResourceNotFoundException: Requested resource not found__
315+
316+
The DynamoDB could not be found. Check your DynamoDB table name and confirm it is named **Wildrydes_Emails** as directed in step 20. If not, recreate the table.
317+
318+
- __ValidationException: One or more parameter values were invalid: Missing the key [column] in the item__
319+
320+
The DynamoDB table was found but the primary key wasn't correctly entered. Check your DynamoDB table settings and confirm the primary key is named **Email** as directed in step 21. If not, recreate the table.
321+
322+
- __AccessDeniedException: User: arn:aws:sts::123456789012:assumed-role/Cognito_wildrydesUnauth_Role/CognitoIdentityCredentials is not authorized to perform: dynamodb:PutItem on resource: arn:aws:dynamodb:us-west-2:123456789012:table/Wildrydes_Emails__
323+
324+
The policy associated with your unauthenticated Cognito role has not been created correctly. Go to **IAM**, click on **Roles**, find and click on **Cognito_wildrydesUnauth_Role**, and click on **Edit Policy**. Ensure the policy you have matches the policy outlined in step 33 exactly.
325+
306326
1. Click **Services** in the navigation bar of the AWS Management Console and select **DynamoDB**.
307327
1. Click **Tables** in the left-hand navigation.
308328
1. Click **Wildrydes_Emails**.

lab1/scripts/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ emailForm.addEventListener('submit', function (event) {
2222
};
2323

2424
dynamoDB.putItem(params, function (err, data) {
25-
if (err) {
26-
console.log(err);
27-
} else {
25+
if (!err) {
2826
formDiv.style.display = 'none';
2927
confirmationDiv.style.display = 'block';
28+
} else {
29+
alert(err);
30+
console.log(err);
3031
}
3132
});
3233
});

0 commit comments

Comments
 (0)