From 49be56ac39e5659f3dddf3f85ee5de9091c400b9 Mon Sep 17 00:00:00 2001 From: benlesh Date: Thu, 15 Mar 2018 21:00:10 -0700 Subject: [PATCH] feat(deprecated-error-handling-warning): add console warning when code sets the flag to bad mode It will console.warn and give the call site (via stack) of where it was set to use the deprecated error handling mode --- src/internal/config.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/internal/config.ts b/src/internal/config.ts index 45b30a0dd0..31de7e244c 100644 --- a/src/internal/config.ts +++ b/src/internal/config.ts @@ -1,3 +1,5 @@ +let _enable_super_gross_mode_that_will_cause_bad_things = false; + /** * The global configuration object for RxJS, used to configure things * like what Promise contructor should used to create Promises @@ -17,5 +19,17 @@ export const config = { * an unhandled error. DO NOT USE THIS FLAG UNLESS IT'S NEEDED TO BY TIME * FOR MIGRATION REASONS. */ - useDeprecatedSynchronousErrorHandling: false, + set useDeprecatedSynchronousErrorHandling(value: boolean) { + if (value) { + const error = new Error(); + console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack); + } else if (_enable_super_gross_mode_that_will_cause_bad_things) { + console.log('RxJS: Back to a better error behavior. Thank you. <3'); + } + _enable_super_gross_mode_that_will_cause_bad_things = value; + }, + + get useDeprecatedSynchronousErrorHandling() { + return _enable_super_gross_mode_that_will_cause_bad_things; + } };