MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / alreadyExistsError

Function alreadyExistsError

console/src/api/materialize/parseErrors.ts:14–32  ·  view source on GitHub ↗
(errorMessage?: string)

Source from the content-addressed store, hash-verified

12 * @returns string object name or null
13 */
14export function alreadyExistsError(errorMessage?: string) {
15 if (!errorMessage) {
16 return null;
17 }
18
19 /**
20 * This regex takes a string and extracts a substring in single or double quotation marks
21 * only if the sentence ends with "already exists".
22 */
23 const strInsideQuotesMatch = /['"]([^'"]*)['"][\s\S]*already exists$/g.exec(
24 errorMessage,
25 );
26
27 if (strInsideQuotesMatch && strInsideQuotesMatch.length > 1) {
28 return strInsideQuotesMatch[1];
29 }
30
31 return null;
32}
33
34/**
35 * Looks for "cannot create multiple replicas named" error messages and returns the object name

Callers 8

onSubmitFunction · 0.90
handleValidSubmitFunction · 0.90
handleConnectionSubmitFunction · 0.90
handleSourceSubmitFunction · 0.90
handleConnectionSubmitFunction · 0.90
handleSourceSubmitFunction · 0.90
handleErrorFunction · 0.90

Calls 1

execMethod · 0.80

Tested by

no test coverage detected