Purposely create compile error to fail the upload
To answer the question asked in the title:

#if some_condition
# error Some error message
#endif


But note that this technique only works at compile time, which
probably makes it useless for you.