Skip to content
Snippets Groups Projects
Commit 64eb3368 authored by michael.minelli's avatar michael.minelli
Browse files

HttpManager => Add possibility to disable error handling

parent 83c73d2c
Branches
Tags
No related merge requests found
......@@ -3,6 +3,7 @@ import Config from '../Config/Config';
import SessionManager from './SessionManager';
import FormData from 'form-data';
import logger from '../shared/logging/WinstonLogger';
import GitlabManager from './GitlabManager';
class HttpManager {
......@@ -10,6 +11,8 @@ class HttpManager {
public LOGIN_URL!: string;
public TEST_SESSION_URL!: string;
public handleCommandErrors: boolean = true;
private static _instance: HttpManager;
public static get instance(): HttpManager {
......@@ -60,6 +63,8 @@ class HttpManager {
return response;
}, (error) => {
if ( error.response ) {
if ( this.handleCommandErrors ) {
if ( error.response.url && error.response.url.indexOf(Config.apiURL) !== -1 ) {
switch ( error.response.status ) {
case 401: // Unauthorized
logger.error('Session expired or inexistent. Please login again.');
......@@ -70,6 +75,10 @@ class HttpManager {
process.exit(1);
break;
}
}
} else {
this.handleCommandErrors = true;
}
} else {
logger.error('Error connecting to the server.');
process.exit(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment