Skip to content

Commit

Permalink
Return error to user on email submission
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jpignata committed Jan 29, 2017
1 parent 6740f13 commit 018dc17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,26 @@ Visitors to your website who are interested in participating in your beta progra

![Confirmation](images/lab1_confirmation.png)

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.

Common errors are:

- __ResourceNotFoundException: Missing credentials in config__

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.

- __ResourceNotFoundException: Requested resource not found__

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.

- __ValidationException: One or more parameter values were invalid: Missing the key [column] in the item__

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.

- __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__

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.

1. Click **Services** in the navigation bar of the AWS Management Console and select **DynamoDB**.
1. Click **Tables** in the left-hand navigation.
1. Click **Wildrydes_Emails**.
Expand Down
7 changes: 4 additions & 3 deletions lab1/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ emailForm.addEventListener('submit', function (event) {
};

dynamoDB.putItem(params, function (err, data) {
if (err) {
console.log(err);
} else {
if (!err) {
formDiv.style.display = 'none';
confirmationDiv.style.display = 'block';
} else {
alert(err);
console.log(err);
}
});
});

0 comments on commit 018dc17

Please sign in to comment.