why.js (1010B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 import { DEBUGGER_PAUSED_REASONS_L10N_MAPPING } from "devtools/shared/constants"; 6 7 export function getPauseReason(why) { 8 if (!why) { 9 return null; 10 } 11 12 const reasonType = why.type; 13 if (!DEBUGGER_PAUSED_REASONS_L10N_MAPPING[reasonType]) { 14 console.log("Please file an issue: reasonType=", reasonType); 15 } 16 17 return DEBUGGER_PAUSED_REASONS_L10N_MAPPING[reasonType]; 18 } 19 20 export function isException(why) { 21 return why?.type === "exception"; 22 } 23 24 export function isInterrupted(why) { 25 return why?.type === "interrupted"; 26 } 27 28 export function inDebuggerEval(why) { 29 if ( 30 why && 31 why.type === "exception" && 32 why.exception && 33 why.exception.preview && 34 why.exception.preview.fileName 35 ) { 36 return why.exception.preview.fileName === "debugger eval code"; 37 } 38 39 return false; 40 }