MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / getInsightOrError

Function getInsightOrError

front_end/testing/InsightHelpers.ts:76–91  ·  view source on GitHub ↗
(
    insightName: InsightName, insights: Trace.Insights.Types.TraceInsightSets,
    navigation?: Trace.Types.Events.NavigationStart)

Source from the content-addressed store, hash-verified

74}
75
76export function getInsightOrError<InsightName extends keyof Trace.Insights.Types.InsightModels>(
77 insightName: InsightName, insights: Trace.Insights.Types.TraceInsightSets,
78 navigation?: Trace.Types.Events.NavigationStart): NonNullable<Trace.Insights.Types.InsightModels[InsightName]> {
79 const insightSet = getInsightSetOrError(insights, navigation);
80 const insight = insightSet.model[insightName];
81 const error = insightSet.modelErrors[insightName];
82 if (error) {
83 // eslint-disable-next-line @typescript-eslint/only-throw-error
84 throw error;
85 }
86 if (!insight) {
87 throw new Error('missing insight');
88 }
89
90 return insight;
91}
92
93export function getFirstOrError<T>(iterator: IterableIterator<T>): T {
94 const result = iterator.next();

Calls 1

getInsightSetOrErrorFunction · 0.85

Tested by 1