Skip to content

Commit

Permalink
error handling and local deployment
Browse files Browse the repository at this point in the history
Error messages improvement and included local development Function settings.
  • Loading branch information
marcusca10 committed Mar 9, 2021
1 parent 89789b5 commit 08a4b1b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## files generated by popular Visual Studio add-ons.

# Azure Functions localsettings file
local.settings.json
//local.settings.json

# User-specific files
*.suo
Expand Down
19 changes: 19 additions & 0 deletions api/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"exclude": [
"**/bin",
"**/bower_components",
"**/jspm_packages",
"**/node_modules",
"**/obj",
"**/platforms"
],
"Host": {
"CORS": "*"
},
"IsEncrypted": false,
"Values": {
"AZUREAD_AUTHORIZED_TENANTS": "[Your tenant ID]",
"AZUREAD_AUDIENCE1": "[The registered app ID for the Herbs Catalog API]",
"AZUREAD_AUDIENCE2": "[The registered app ID for the Cactus Catalog API]"
}
}
18 changes: 17 additions & 1 deletion app/src/components/TokenComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,23 @@ class TokenComponent extends Component {
},
(err) => {
this.setState({resultDetails: ''});
this.showMessage('danger', 'Error', err.message)
var message = err.message;
if (err.response) {
switch (err.response.status) {
case 403:
message = message + ', verify that you selected the right scope to call the API!';
break;
case 500:
message = message + ', did you remember to update the Azure Function Configuration?';
break;
default:
break;
}
}
else {
message = err.message === 'Network Error' ? message + ', did you remember to configure CORS for the Azure Function?' : message;
}
this.showMessage('danger', 'Error', message)
console.log(err);
}
)
Expand Down

0 comments on commit 08a4b1b

Please sign in to comment.