Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Display error when service instance creation fails #1173

Merged
merged 1 commit into from
Jul 31, 2017

Conversation

el-mapache
Copy link
Contributor

Screenshots!

screen shot 2017-07-28 at 4 46 12 pm

screen shot 2017-07-28 at 4 45 43 pm

@el-mapache el-mapache self-assigned this Jul 28, 2017
@el-mapache
Copy link
Contributor Author

el-mapache commented Jul 28, 2017

Due to the structure of the form component's html, server errors are displayed before the 'There were errors submitting the form'.


serviceActions.errorCreateInstance(originalError);

const actionInfo = spy.getCall(0).args[0];
Copy link
Contributor Author

@el-mapache el-mapache Jul 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not using the test helpers here as I was having a hard time getting the test to validate when the arguments passed to the dispatch function are objects.

const argumentError = { response: { data: { error_code: 'CF-MessageParseError' } } };
const spaceError = { response: { data: { error_code: 'CF-ServiceInstanceInvalid' } } };
const serverErrorMsg =
'Error #500: please contact cloud.gov support for help troubleshooting this issue.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know if you think this would be something for another PR: would be nice to remove the cloud.gov hard coding so that in the future we can achieve #790 eventually

Copy link
Contributor Author

@el-mapache el-mapache Jul 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree. Do we have any concept of the app environment baked into the build process or anything? I think we can have webpack set a global variable that will get injected into the app code. Then 'cloud.gov' could just be whatever platform the dashboard is running on.

In that case, the client setting up the dashboard would need to replace 'cloud.gov' with whatever the name of their platform is.

errorCreateInstance(err) {
errorCreateInstance(error) {
const { response } = error;
const safeError = (response && response.data) || { code: 500 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coming from a non-JS perspective:

it looks like (response && response.data) could evaluate to true or false.
if true, safeError would be set to true.

if false, it would set safeError to {code: 500};

Now your tests, tell me it doesn't work that way, but just could be a little confusing at first glance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, don't you also neederror_code to make sure this is a safe error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this construct in JS, if the first argument evaluates to true, and the second argument is also true, the second argument will be executed. In this instance, executing means storing the value of the second argument in a variable, but you could, for example, pass a function as the second argument.

If the second argument is also false, the fallback will be executed instead.

I concede that this might look a little confusing but it is a pretty common in JS.

If I misunderstood the question, and you already knew this, sorry 😬 !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcscottiii For your second comment, error_code needn't be present, the store checks for the existence of one and returns the generic 500 error message if it isn't present.

Copy link
Contributor

@jcscottiii jcscottiii Jul 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the first one, I've seen it done like this with ternary operators commonly. condition ? happy case : sad case but sounds good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the second one: ahh i gotcha.

@el-mapache el-mapache force-pushed the ab-service-instance-bind-errors branch from 3bbe8f9 to b53d3b5 Compare July 31, 2017 17:52
@el-mapache
Copy link
Contributor Author

I mistakenly misnamed this PR's branch, it covers error handling when creating a service instance, not binding a service instance.

@jcscottiii jcscottiii merged commit decc308 into master Jul 31, 2017
@jcscottiii jcscottiii deleted the ab-service-instance-bind-errors branch July 31, 2017 18:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants