2018-07-12 14:11:31 +02:00
|
|
|
import { Observable, of } from 'rxjs';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* injects the {@link DataStoreService} to all its children and provides a generic function to catch errors
|
|
|
|
* should be abstract and a mere parent to all {@link DataStoreService} accessors
|
|
|
|
*/
|
|
|
|
export abstract class OpenSlidesComponent {
|
|
|
|
/**
|
|
|
|
* Empty constructor
|
|
|
|
*
|
|
|
|
* Static injection of {@link DataStoreService} in all child instances of OpenSlidesComponent
|
|
|
|
* Throws a warning even tho it is the new syntax. Ignored for now.
|
|
|
|
*/
|
2018-08-29 13:21:25 +02:00
|
|
|
public constructor() {}
|
2018-07-12 14:11:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic error handling for everything that makes HTTP Calls
|
|
|
|
* TODO: could have more features
|
|
|
|
* @return an observable error
|
|
|
|
*/
|
2018-09-07 13:12:59 +02:00
|
|
|
public handleError<T>(): (error: any) => Observable<T> {
|
2018-07-12 14:11:31 +02:00
|
|
|
return (error: any): Observable<T> => {
|
|
|
|
console.error(error);
|
|
|
|
return of(error);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|