Skip to content

Commit

Permalink
exit with non-zero if not 200
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmarsh committed Nov 7, 2024
1 parent 2af178c commit bf1113c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions _jnja/engine.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ def engine(elm, **kwargs):
logging.debug('response.headers.X-Rate-Limit-Remaining: %s', response.headers['X-Rate-Limit-Remaining'])
logging.debug('response.headers.X-Rate-Limit-Window: %s', response.headers['X-Rate-Limit-Window'])
response.raise_for_status()
except:
click.secho('An error occured', fg='red', err=True)
click.secho(elm.command, fg='red', err=True)
click.secho(elm.path, fg='red', err=True)
click.secho(str(flags), fg='red', err=True)
except requests.RequestException as e:
click.secho('Error: request failed', fg='red', err=True)
click.secho(f'Command: {elm.command}', fg='red', err=True)
click.secho(f'Path: {elm.path}', fg='red', err=True)
click.secho(f'Flags: {str(flags)}', fg='red', err=True)

logging.error('request failed: %s', e)
sys.exit(1) # Exit with a non-zero status code

logging.info('response.url: %s', response.url)
logging.info('response.status_code: %s', response.status_code)
Expand Down

0 comments on commit bf1113c

Please sign in to comment.