fix(doctor): fail gracefully in case of unexpected error (#132)
This commit is contained in:
parent
47f64b51af
commit
6ab5c549c1
2 changed files with 16 additions and 8 deletions
|
|
@ -87,7 +87,7 @@ export const RepositoryInfoTabContent = ({ repository }: Props) => {
|
|||
<p className="text-sm text-muted-foreground">Unique identifier for the repository.</p>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="compressionMode">Compression Mode</Label>
|
||||
<Label htmlFor="compressionMode">Compression mode</Label>
|
||||
<Select value={compressionMode} onValueChange={(val) => setCompressionMode(val as CompressionMode)}>
|
||||
<SelectTrigger id="compressionMode">
|
||||
<SelectValue placeholder="Select compression mode" />
|
||||
|
|
@ -115,11 +115,11 @@ export const RepositoryInfoTabContent = ({ repository }: Props) => {
|
|||
<p className="mt-1 text-sm">{repository.status || "unknown"}</p>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm font-medium text-muted-foreground">Created At</div>
|
||||
<p className="mt-1 text-sm">{new Date(repository.createdAt * 1000).toLocaleString()}</p>
|
||||
<div className="text-sm font-medium text-muted-foreground">Created at</div>
|
||||
<p className="mt-1 text-sm">{new Date(repository.createdAt).toLocaleString()}</p>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm font-medium text-muted-foreground">Last Checked</div>
|
||||
<div className="text-sm font-medium text-muted-foreground">Last checked</div>
|
||||
<p className="mt-1 text-sm">
|
||||
{repository.lastChecked ? new Date(repository.lastChecked).toLocaleString() : "Never"}
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -360,23 +360,31 @@ const doctorRepository = async (name: string) => {
|
|||
error: recheckResult.error,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
steps.push({
|
||||
step: "unexpected_error",
|
||||
success: false,
|
||||
output: null,
|
||||
error: toMessage(error),
|
||||
});
|
||||
} finally {
|
||||
releaseLock();
|
||||
}
|
||||
|
||||
const allSuccessful = steps.every((s) => s.success);
|
||||
const doctorSucceeded = steps.every((step) => step.success);
|
||||
const doctorError = steps.find((step) => step.error)?.error ?? null;
|
||||
|
||||
await db
|
||||
.update(repositoriesTable)
|
||||
.set({
|
||||
status: allSuccessful ? "healthy" : "error",
|
||||
status: doctorSucceeded ? "healthy" : "error",
|
||||
lastChecked: Date.now(),
|
||||
lastError: allSuccessful ? null : steps.find((s) => !s.success)?.error,
|
||||
lastError: doctorError,
|
||||
})
|
||||
.where(eq(repositoriesTable.id, repository.id));
|
||||
|
||||
return {
|
||||
success: allSuccessful,
|
||||
success: doctorSucceeded,
|
||||
steps,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue