本文整理匯總了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);
}