Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit cc5d7ce

Browse files
authored
chore: error handling (#788)
1 parent 8568f9a commit cc5d7ce

File tree

7 files changed

+17
-7
lines changed

7 files changed

+17
-7
lines changed

cortex-js/src/infrastructure/commanders/embeddings.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class EmbeddingCommand extends CommandRunner {
6565
inspect(res, { showHidden: false, depth: null, colors: true }),
6666
)
6767
.then(console.log)
68-
.catch(console.error);
68+
.catch((e) => console.error(e.message ?? e));
6969
}
7070

7171
modelInquiry = async (models: ModelStat[]) => {

cortex-js/src/infrastructure/commanders/models/model-pull.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ModelPullCommand extends CommandRunner {
3838
await this.modelsCliUsecases.pullModel(modelId).catch((e: Error) => {
3939
if (e instanceof ModelNotFoundException)
4040
console.error('Model does not exist.');
41-
else console.error(e);
41+
else console.error(e.message ?? e);
4242
exit(1);
4343
});
4444

cortex-js/src/infrastructure/commanders/serve.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class ServeCommand extends CommandRunner {
4343
chalk.blue(`API Playground available at http://${host}:${port}/api`),
4444
);
4545
} catch (err) {
46-
console.error(err.message);
46+
console.error(err.message ?? err);
4747
}
4848
}
4949

cortex-js/src/infrastructure/commanders/shortcuts/run.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class RunCommand extends CommandRunner {
5959
await this.modelsCliUsecases.pullModel(modelId).catch((e: Error) => {
6060
if (e instanceof ModelNotFoundException)
6161
console.error('Model does not exist.');
62-
else console.error(e);
62+
else console.error(e.message ?? e);
6363
exit(1);
6464
});
6565
}

cortex-js/src/infrastructure/commanders/usecases/chat.cli.usecases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class ChatCliUsecases {
149149
let assistantResponse: string = '';
150150

151151
response.on('error', (error: any) => {
152-
console.error(error);
152+
console.error(error.message ?? error);
153153
if (attach) rl.prompt();
154154
else rl.close();
155155
});

cortex-js/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async function bootstrap() {
1818
chalk.blue(`API Playground available at http://${host}:${port}/api`),
1919
);
2020
} catch (err) {
21-
console.error(err.message);
21+
console.error(err.message ?? err);
2222
}
2323
}
2424

cortex-js/src/usecases/models/models.usecases.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,18 @@ export class ModelsUsecases {
408408
throw new BadRequestException('Model already exists');
409409
}
410410

411-
// Fetch the repo data
411+
// ONNX only supported on Windows
412+
if (modelId.includes('onnx') && process.platform !== 'win32') {
413+
throw new BadRequestException('ONNX models are not supported on this OS');
414+
}
415+
416+
if (modelId.includes('tensorrt-llm') && process.platform === 'darwin') {
417+
throw new BadRequestException(
418+
'Tensorrt-LLM models are not supported on this OS',
419+
);
420+
}
412421

422+
// Fetch the repo data
413423
const data = await this.fetchModelMetadata(modelId);
414424
// Pull the model.yaml
415425
await this.populateHuggingFaceModel(

0 commit comments

Comments
 (0)