🥅 improved error handling for codebase indexing
This commit is contained in:
parent
ed6fce5d56
commit
2aaeefd018
3 changed files with 34 additions and 20 deletions
|
|
@ -104,10 +104,16 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
|
|||
|
||||
for (let i = 0; i < results.compute.length; i++) {
|
||||
const compute = results.compute[i];
|
||||
const snippets = await this.getSnippetsInFile(
|
||||
compute.path,
|
||||
await this.ide.readFile(compute.path),
|
||||
);
|
||||
|
||||
let snippets: (ChunkWithoutID & { title: string })[] = [];
|
||||
try {
|
||||
snippets = await this.getSnippetsInFile(
|
||||
compute.path,
|
||||
await this.ide.readFile(compute.path),
|
||||
);
|
||||
} catch (e) {
|
||||
// If can't parse, assume malformatted code
|
||||
}
|
||||
|
||||
// Add snippets to sqlite
|
||||
for (const snippet of snippets) {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ export class LanceDbIndex implements CodebaseIndex {
|
|||
chunks.map((c) => c.content),
|
||||
);
|
||||
|
||||
if (embeddings.some((emb) => emb === undefined)) {
|
||||
throw new Error(
|
||||
`Failed to generate embedding for ${chunks[0]?.filepath} with provider: ${this.embeddingsProvider.id}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Create row format
|
||||
for (let j = 0; j < chunks.length; j++) {
|
||||
const progress = (i + j / chunks.length) / items.length;
|
||||
|
|
|
|||
|
|
@ -88,21 +88,21 @@ export class CodebaseIndexer {
|
|||
const repoName = await this.ide.getRepoName(directory);
|
||||
let completedIndexes = 0;
|
||||
|
||||
try {
|
||||
for (let codebaseIndex of indexesToBuild) {
|
||||
// TODO: IndexTag type should use repoName rather than directory
|
||||
const tag: IndexTag = {
|
||||
directory,
|
||||
branch,
|
||||
artifactId: codebaseIndex.artifactId,
|
||||
};
|
||||
const [results, markComplete] = await getComputeDeleteAddRemove(
|
||||
tag,
|
||||
{ ...stats },
|
||||
(filepath) => this.ide.readFile(filepath),
|
||||
repoName,
|
||||
);
|
||||
for (let codebaseIndex of indexesToBuild) {
|
||||
// TODO: IndexTag type should use repoName rather than directory
|
||||
const tag: IndexTag = {
|
||||
directory,
|
||||
branch,
|
||||
artifactId: codebaseIndex.artifactId,
|
||||
};
|
||||
const [results, markComplete] = await getComputeDeleteAddRemove(
|
||||
tag,
|
||||
{ ...stats },
|
||||
(filepath) => this.ide.readFile(filepath),
|
||||
repoName,
|
||||
);
|
||||
|
||||
try {
|
||||
for await (let { progress, desc } of codebaseIndex.update(
|
||||
tag,
|
||||
results,
|
||||
|
|
@ -136,9 +136,11 @@ export class CodebaseIndexer {
|
|||
workspaceDirs.length,
|
||||
desc: "Completed indexing " + codebaseIndex.artifactId,
|
||||
};
|
||||
} catch (e) {
|
||||
console.warn(
|
||||
`Error updating the ${codebaseIndex.artifactId} index: ${e}`,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Error refreshing index: ", e);
|
||||
}
|
||||
|
||||
completedDirs++;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue