Servo stuck when it gets jammed

Hi everyone.
I'm new to Arduino coding & I'm working on a project that where I use the servo as a lock. I cant figure out how to set up the programming. I was hoping that someone would be able to assist me regarding the problem I'm having.

I have a servo, that I want to be at position = 175 while the push button is in the LOW position(locked) and when in the HIGH position I need the servo to be in position = 25(open), this all works ok.

My problem is when the servo gets stuck because it got jammed due to that the lock position has not lined up to lock. When this happen the servo no longer responds to the push button signal.

I need the lock to go back to the open position if it can't lock after 3 tries and give me alarm that the it did not lock.

Will this be possible? I would appreciate if someone could assist me.

Herewith my code I,m using:

#include <Servo.h>

Servo myservo; // create servo object to control a servo

// variables that wont change:
const int buttonPin = 9; // the pin that the pushbutton is attached to
const int ledPin = LED_BUILTIN; // the pin that the LED is connected to
const int digIn1 = 2; // the pin that is connected to DIGIN1 on IoT Unit

// variables that will change:
int buttonState = 0; // current state of the button
int pos = 0; // Variable to store the servo position

void setup() {

// initial position is closed
digitalWrite(pos, 175);

// attach the servo to pin
myservo.attach(7);

// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
digitalWrite(9, LOW);
pinMode(ledPin, OUTPUT);
pinMode(digIn1, OUTPUT);
}

void loop() {

// read the button input pin:
buttonState = digitalRead(buttonPin);

if (buttonState == LOW)
{
// move to position 175 to close lock
myservo.write(175);
digitalWrite(ledPin, LOW); // turn off LED
digitalWrite(digIn1, LOW); // tell IoT Unit that lock is closed
}

else if (buttonState != LOW)
{
// move to position 25 to open lock
myservo.write(25);
digitalWrite(ledPin, HIGH); // turn on LED
digitalWrite(digIn1, HIGH); // tell IoT Unit that lock is open
}

}

How will the Arduino know that the servo has got stuck ?