further remove isolate fn
Change-Id: Ib814af5020bf2232afc533bb07438f88e9df271c Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/339160 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Charley Kline <ckline@instructure.com> QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com> Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
This commit is contained in:
parent
b0301bd5fc
commit
8b7d2c4925
|
@ -15,7 +15,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {isolate} from '@canvas/sentry'
|
||||
import KeyboardNavDialog from '@canvas/keyboard-nav-dialog'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import $ from 'jquery'
|
||||
|
@ -645,7 +644,5 @@ export default function enhanceTheEntireUniverse() {
|
|||
makeAllExternalLinksExternalLinks,
|
||||
wireUpFilePreview,
|
||||
setDialogCloseText,
|
||||
]
|
||||
.map(isolate)
|
||||
.map(x => x())
|
||||
].map(x => x())
|
||||
}
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2022 - present Instructure, Inc.
|
||||
*
|
||||
* This file is part of Canvas.
|
||||
*
|
||||
* Canvas is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3 of the License.
|
||||
*
|
||||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {isolate} from '..'
|
||||
|
||||
describe('isolate', () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
it('isolates throws from function', async () => {
|
||||
await isolate(() => {
|
||||
throw new Error('nope')
|
||||
})()
|
||||
expect(console.error).toHaveBeenCalledWith(new Error('nope'))
|
||||
})
|
||||
|
||||
it('isolates throws from async function', async () => {
|
||||
await isolate(async () => {
|
||||
throw new Error('nope')
|
||||
})()
|
||||
expect(console.error).toHaveBeenCalledWith(new Error('nope'))
|
||||
})
|
||||
|
||||
it('isolates rejections returned by function', async () => {
|
||||
await isolate(() => Promise.reject(new Error('nope')))()
|
||||
expect(console.error).toHaveBeenCalledWith(new Error('nope'))
|
||||
})
|
||||
|
||||
it('isolates rejections returned by async function', async () => {
|
||||
await isolate(async () => Promise.reject(new Error('nope')))()
|
||||
expect(console.error).toHaveBeenCalledWith(new Error('nope'))
|
||||
})
|
||||
|
||||
it('isolates rejections awaited by async function', async () => {
|
||||
await isolate(async () => {
|
||||
await Promise.reject(new Error('nope'))
|
||||
})()
|
||||
expect(console.error).toHaveBeenCalledWith(new Error('nope'))
|
||||
})
|
||||
})
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2022 - present Instructure, Inc.
|
||||
*
|
||||
* This file is part of Canvas.
|
||||
*
|
||||
* Canvas is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3 of the License.
|
||||
*
|
||||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {captureException} from '@sentry/browser'
|
||||
|
||||
// Call a function for its side-effects. If it fails, don't unwind the stack,
|
||||
// instead just log the exception to Sentry and to the console.
|
||||
export function isolate(f) {
|
||||
return async function () {
|
||||
try {
|
||||
// DON'T propagate the return value; if they actually need it they should
|
||||
// be doing this by hand instead
|
||||
await f.apply(this, arguments)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
captureException(e)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"name": "@canvas/sentry",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"exports": {
|
||||
".": "./index.js"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue