From 733b2e1421d8b70db91cc5dabe5018c8bfafb2a1 Mon Sep 17 00:00:00 2001 From: Arcane Engine Date: Sun, 13 Oct 2024 00:34:55 +0000 Subject: [PATCH] Add error handling to generate_client.sh for improved robustness and feedback on failures. --- generate_client.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/generate_client.sh b/generate_client.sh index f063092..04b124a 100755 --- a/generate_client.sh +++ b/generate_client.sh @@ -1,5 +1,22 @@ -docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ +#!/bin/bash + +# Function to handle errors +echo_error() { + echo "Error: $1" >&2 +} + +# Check if Docker is installed +docker --version >/dev/null 2>&1 || { echo_error "Docker is not installed. Please install Docker and try again."; exit 1; } + +# Run the OpenAPI Generator +if ! docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ -i https://arcane.engineer/api/openapi.yaml \ -g python \ --additional-properties generateSourceCodeOnly=true,projectName=arcane-engine,packageName=arcane \ - -o /local \ No newline at end of file + -o /local; then + echo_error "Failed to generate client code. Please check the OpenAPI specification and try again." + exit 1 +fi + +# Success message +echo "Client code generated successfully."