validate-breakpoint.sys.mjs (1203B)
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 /** 6 * Given a breakpoint location object, throws if the breakpoint look invalid 7 */ 8 export function validateBreakpointLocation({ 9 sourceUrl, 10 sourceId, 11 line, 12 column, 13 }) { 14 if (!sourceUrl && !sourceId) { 15 throw new Error( 16 `Breakpoints expect to have either a sourceUrl or a sourceId.` 17 ); 18 } 19 if (sourceUrl && typeof sourceUrl != "string") { 20 throw new Error( 21 `Breakpoints expect to have sourceUrl string, got ${typeof sourceUrl} instead.` 22 ); 23 } 24 // sourceId may be undefined for some sources keyed by URL 25 if (sourceId && typeof sourceId != "string") { 26 throw new Error( 27 `Breakpoints expect to have sourceId string, got ${typeof sourceId} instead.` 28 ); 29 } 30 if (typeof line != "number") { 31 throw new Error( 32 `Breakpoints expect to have line number, got ${typeof line} instead.` 33 ); 34 } 35 if (typeof column != "number") { 36 throw new Error( 37 `Breakpoints expect to have column number, got ${typeof column} instead.` 38 ); 39 } 40 }