File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
packages/ember-cli-fastboot/fastboot/initializers
test-packages/test-scenarios Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 11/* eslint-disable prettier/prettier */
2- import Ember from 'ember' ;
2+ import { getOnerror , setOnerror } from '@ ember/-internals/error-handling ' ;
33
44/**
55 * Initializer to attach an `onError` hook to your app running in fastboot. It catches any run loop
@@ -10,12 +10,12 @@ export default {
1010 name : 'error-handler' ,
1111
1212 initialize : function ( ) {
13- if ( ! Ember . onerror ) {
13+ if ( ! getOnerror ( ) ) {
1414 // if no onerror handler is defined, define one for fastboot environments
15- Ember . onerror = function ( err ) {
15+ setOnerror ( function ( err ) {
1616 const errorMessage = `There was an error running your app in fastboot. More info about the error: \n ${ err . stack || err } ` ;
1717 console . error ( errorMessage ) ;
18- }
18+ } ) ;
1919 }
2020 }
2121} ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ appScenarios
2424 });
2525 });` ,
2626 'instance-initializers' : {
27- 'setup-onerror.js' : `import Ember from 'ember';
27+ 'setup-onerror.js' : `import { setOnerror } from '@ ember/-internals/error-handling ';
2828 export function initialize(owner) {
2929 let isFastBoot = typeof 'FastBoot' !== 'undefined';
3030 let fastbootRequestPath;
@@ -36,12 +36,12 @@ appScenarios
3636
3737 console.log('setting up error handler ' + fastbootRequestPath);
3838
39- Ember.onerror = function (error) {
39+ setOnerror( function (error) {
4040 if (isFastBoot) {
4141 error.fastbootRequestPath = fastbootRequestPath;
4242 throw error;
4343 }
44- };
44+ }) ;
4545 }
4646
4747 export default {
@@ -52,12 +52,15 @@ appScenarios
5252 routes : {
5353 'application.js' : `import Route from '@ember/routing/route';
5454 import { action } from '@ember/object';
55- import Ember from 'ember';
55+ import { getOnerror } from '@ ember/-internals/error-handling ';
5656
5757 export default class ApplicationRoute extends Route {
5858 @action
5959 error(err) {
60- Ember.onerror(err);
60+ const onerror = getOnerror();
61+ if (onerror) {
62+ onerror(err);
63+ }
6164 }
6265 }
6366 ` ,
You can’t perform that action at this time.
0 commit comments