I want to log exceptions generated in typescript to a log file (text file). I want to log information like description,message,name,number,stack. I have written Model, API Controller and logic to write the data into text file.
However I want to map Error Response generated after get, post,put operation in typescript. I have written below Interface
export interface TypeScriptException {
Description: string;
Message: string;
Name: string;
Number: string;
ErrorStack: string;
}
When handleError method is called after Post in below example, how do I assign values from Error Response to my TypeScriptException object?
post(url: string, model: any): Observable<any> {
let body = JSON.stringify(model);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this._http.post(url, body, options)
.map((response: Response) => <any>response.json())
.catch(this.handleError);
}
private handleError(error: Response) {
let typeScriptException: TypeScriptException;
//What to do here
}

error?