Skip to content

Commit

Permalink
refactor: improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
KarimAziev committed Nov 27, 2024
1 parent 31760e6 commit ed8c209
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions build-emacs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,21 @@ pull_emacs() {
if [ ! -d "$EMACS_DIRECTORY" ]; then
echo "Cloning emacs"

git clone --depth 1 "$EMACS_REMOTE_URL" "$EMACS_DIRECTORY"
cd "$EMACS_DIRECTORY" || exit 1
if ! git clone --depth 1 "$EMACS_REMOTE_URL" "$EMACS_DIRECTORY"; then
echo "Error: Failed to clone Emacs repository. Check the URL or network connection."
exit 1
fi

cd "$EMACS_DIRECTORY" || {
echo >&2 "Error: The Emacs directory '$EMACS_DIRECTORY' does not exist."
exit 1
}

else
cd "$EMACS_DIRECTORY" || exit 1
cd "$EMACS_DIRECTORY" || {
echo >&2 "Error: The Emacs directory '$EMACS_DIRECTORY' does not exist."
exit 1
}

current_origin_url=$(git remote get-url origin)

Expand All @@ -276,7 +286,10 @@ pull_emacs() {

remove_emacs() {
if [ -d "$EMACS_DIRECTORY" ]; then
cd "$EMACS_DIRECTORY" || exit 1
cd "$EMACS_DIRECTORY" || {
echo >&2 "Error: The Emacs directory '$EMACS_DIRECTORY' does not exist."
exit 1
}
echo "Uninstalling Emacs"
sudo make uninstall
echo "Cleaning Emacs"
Expand Down

0 comments on commit ed8c209

Please sign in to comment.