本文整理汇总了TypeScript中@angular/http.Response.toString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Response.toString方法的具体用法?TypeScript Response.toString怎么用?TypeScript Response.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/http.Response
的用法示例。
在下文中一共展示了Response.toString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: handleError
private handleError( res: Response ) {
console.log( "handleError: " + res.toString() );
console.log( "res.status: " + res.status );
console.log( "Checking login" );
if ( res.status === 401 || res.status === 403 ) {
// console.log( "send to login. cause: " + res.toString() );
this.router.navigate( ['/login'] );
}
console.log( "Checking errors" );
try {
var json = res.json();
console.log( "jsonErrors: " + JSON.stringify( json ) );
if ( json.actionErrors && Object.keys( json.actionErrors ).length > 0 ) {
console.log( "alertErrors: " + JSON.stringify( json.actionErrors ) );
this.alertService.error( json.actionErrors, false );
}
} catch ( e ) {
console.log( "not json!!!" );
this.alertService.error( [res.toString()], false );
}
return Observable.throw( res );
}
示例2: handleError
private handleError (error: Response | any) {
console.error("origin error: " + error);
// In a real world app, we might use a remote logging infrastructure
let errMsg: string;
if (error instanceof Response) {
errMsg = error.toString();
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error("error: " + errMsg);
return Observable.throw(errMsg);
}
示例3: handleError
private handleError(error: Response | any) {
this.loadingBar.color = 'red';
this.loadingBar.complete();
let message: string;
if (error instanceof Response) {
if (error.status === 0) {
message = `Could not reach the bhmc server because your internet connection
was lost, the connection timed out, or the server is not responding.`;
} else {
const body = error.json() || {};
if (body.non_field_errors) {
// django-rest-auth
message = body.non_field_errors[0];
} else if (body.username) {
// django-rest-auth
message = body.username[0];
} else if (body.detail) {
// django-rest-framework
message = body.detail;
} else {
message = JSON.stringify(body);
}
}
this.errorHandler.logResponse(message, error);
} else {
this.errorHandler.logError(error);
message = error.message ? error.message : error.toString();
}
this.errorSource.next(message);
return Observable.throw(message);
}
示例4: handleError
private handleError (error: Response | any) {
let errMsg: string;
const body = error.json() || '';
errMsg = error.message ? error.message : error.toString();
console.error(errMsg);
return Observable.throw(body);
}
示例5: handlerError
static handlerError(error: Response | any) {
let errorMessage: string;
if (error instanceof Response) {
errorMessage = `Erro ${error.status} ao acessar a URL ${error.url} = ${error.statusText}`;
} else {
errorMessage = error.toString();
};
return Observable.throw(errorMessage);
}
示例6: handleError
static handleError(error: Response | any){
let errorMessage: string
if (error instanceof Response){
errorMessage = `Erro ${error.url} ao obter a url ${error.url} - ${error.statusText}`
}else{
errorMessage = error.toString()
}
console.log(errorMessage)
return Observable.throw(errorMessage)
}
示例7: onFailurResponse
private onFailurResponse(error: Response | any) {
let errMsg: string;
if (error instanceof Response) {
const body = error.json() || '';
const err = body.error || JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
return Observable.throw(errMsg);
}
示例8: handleError
handleError(error: Response | any){
let errMsg: string;
if (error instanceof Response) {
const body = error.json() || '';
const err = body.error || JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
return Promise.reject(errMsg);
}
示例9: handleError
private handleError(error: Response | any) {
let errMsg: string;
if (error instanceof Response) {
errMsg = `${error.status} - ${error.ok || ''}`;
if (error.status === 0) {
errMsg = `${error.status} - "No Internet"`;
}
} else {
errMsg = error.message ? error.message : error.toString();
}
return Observable.throw(errMsg);
}
示例10: loadError
loadError(error: Response | any) {
console.error(error);
let errMsg: string;
if (error instanceof Response) {
const body = error.json() || '';
errMsg = body.message || JSON.stringify(body);
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error(errMsg);
return Observable.throw(errMsg);
}