Permalink
Switch branches/tags
Nothing to show
Find file Copy path
39d7ae9 Feb 23, 2018
0 contributors

Users who have contributed to this file

28 lines (20 sloc) 695 Bytes
import { Observable } from 'rxjs/Rx';
export abstract class BaseService {
protected readonly api = 'http://localhost:5000/api';
protected handleError(error: any) {
const applicationError = error.headers['Application-Error'];
if (applicationError) {
return Observable.throw(applicationError);
}
let modelStateErrors: any = '';
if (error.data) {
for (const key in error.data) {
if (error.data[key]) {
modelStateErrors += error.data[key] + '\n';
}
}
}
modelStateErrors = modelStateErrors = '' ? null : modelStateErrors;
return Observable.throw(modelStateErrors || 'Server error');
}
}