lgalfaso / angular-dynamic-locale

Module to be able to change the locale at an angularjs application
http://lgalfaso.github.io/angular-dynamic-locale/
MIT License
322 stars 75 forks source link

Karma failure due to 'Possibly Unhandled Rejection' #117

Closed Deklin closed 5 years ago

Deklin commented 7 years ago

So if karma can't load the required file, we are getting an error

the string "Possibly unhandled rejection: en-us" was thrown, throw an Error :)

Is there a way to define the rejection handler in the config phase for the dynamic locale?

lgalfaso commented 7 years ago

Would it be possible to know what are you specifically looking for?

When there is an error with the locale loading, there is a broadcast of type $localeChangeError would this be enough for the issue you are facing?

On Fri, Oct 6, 2017 at 12:01 AM Steve Berube notifications@github.com wrote:

So if karma can't load the required file, we are getting an error

the string "Possibly unhandled rejection: en-us" was thrown, throw an Error :)

Is there a way to define the rejection handler in the config phase for the dynamic locale?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lgalfaso/angular-dynamic-locale/issues/117, or mute the thread https://github.com/notifications/unsubscribe-auth/AAX44tPCfU1hNa1zRlMFEM6z1FziKMSWks5spVGfgaJpZM4Pvwow .

Deklin commented 7 years ago

We are trying to figure out how to get by this.

What would be helpful is in the config phase to set a rejection method so we can log or toss the rejection. Because its unhandled when we do our unit tests right now, this is failing because of the unhandled rejection

something like;

tmhDynamicLocaleProvider.onLocaleLoadFailure(function(e) { // Toss the error. };

I'm assuming somewhere there is a promise that is rejecting based on not loading the requested locale file, if we can swallow that or at least have a way to process it, that should solve it.

Deklin commented 7 years ago

I am also reviewing the code now to see if I can explain better or find the actual problem.

lgalfaso commented 7 years ago

tmhDynamicLocale.set returns a promise that is rejected when loading the locale fails.

On Fri, Oct 6, 2017 at 11:03 PM Steve Berube notifications@github.com wrote:

I am also reviewing the code now to see if I can explain better or find the actual problem.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/lgalfaso/angular-dynamic-locale/issues/117#issuecomment-334869505, or mute the thread https://github.com/notifications/unsubscribe-auth/AAX44io88Xx4W378E033rB8zfeDVU2Pgks5sppWPgaJpZM4Pvwow .

lgalfaso commented 5 years ago

From the last comment, my understanding is that this issue is resolved.

rgeraldporter commented 1 year ago

In case anyone else in the future needs a code example of the solution here, when setting the locale, define a catch with an empty function:

tmhDynamicLocale.set('en-US').catch(() => {});