This repository has been archived by the owner on Mar 21, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 178
Try-Catch not working as expected #466
Comments
This issue seems related to https://github.com/jhipster/jhipster-vuejs. |
Thanks, I transfered the issue here |
Just to clarify, the
is your custom code and not generated by jhipster-vuejs, right? I think the service classes we generate are intended to be used without |
@atomfrede : for your information, @hdurix suggested to @levitesm to open a ticket here, as there is maybe a missing part in our service, using Vue.js |
@pascalgrimaud Good to know, it indeed looks a little bit like we have something missing here. |
try-catch is my code.
But even if I use .then().catch() instead, the catch still will not work.
Async-await is just another version of doing the same.
пн, 7 окт. 2019 г. в 17:23, Frederik Hahne <[email protected]>:
… @pascalgrimaud <https://github.com/pascalgrimaud> Good to know, it indeed
looks a little bit like we have something missing here.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#466?email_source=notifications&email_token=AKFL4L44W2KGECB2CDLXZ3DQNNA4VA5CNFSM4I6E5I62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAQQWRQ#issuecomment-539036486>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKFL4L37DQYYLOPW3WHTN7TQNNA4VANCNFSM4I6E5I6Q>
.
|
4 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello!
I have a question regarding the code generated by JHipster.
I'm using the Vue.Js blueprint.
In all the services for each entity in frontend JHipster is generating several standard functions which look like this:
public update(entity: ICompetitors): Promise {
return new Promise(resolve => {
axios.put(
${baseApiUrl}
, entity).then(function(res) {resolve(res.data);
}));
});
}
When I'm calling that function I'm doing something like this:
try {
await this.competitorsService().update(this.competitor);
} catch {
this.savingError = true;
}
But the CATCH is not working, because the promise created in the Update function is not rejected....
So to fix this, I need to change the generated Update function to this:
public update(entity: ICompetitors): Promise {
return new Promise((resolve, reject) => {
axios.put(
${baseApiUrl}
, entity).then(function(res) {resolve(res.data);
}).catch(err => {reject(err.message)});
});
}
So my question is: why are those functions generated like this?
Why is not the Promise rejected in case of an error?
Is this a mistake in JHipster? Or were those functions intended to be used in a different way?
Thanks a lot for you help!!
Mark.
jhipster info
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:info
INFO! Options: from-cli: true
Welcome to the JHipster Information Sub-Generator
JHipster Version(s)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
git version 2.20.1 (Apple Git-117)
node: v10.15.3
npm: 6.10.3
Docker version 19.03.1, build 74b1e89
docker-compose version 1.24.1, build 4667896b
INFO! Congratulations, JHipster execution is complete!
MBP-Konstantin:Kompetitors2 marklevites$
The text was updated successfully, but these errors were encountered: