当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Response.toString方法代码示例

本文整理汇总了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 );
    }
开发者ID:xeredi,项目名称:portico,代码行数:25,代码来源:http.interceptor.ts

示例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);
 }
开发者ID:qwb0920,项目名称:ionic2-GGDream,代码行数:12,代码来源:HttpClient.ts

示例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);
    }
开发者ID:finleysg,项目名称:bhmc,代码行数:33,代码来源:bhmc-data.service.ts

示例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);
 }
开发者ID:mazraara,项目名称:laravel-angular-admin,代码行数:7,代码来源:register.service.ts

示例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);
 }
开发者ID:dancasttro,项目名称:labs,代码行数:9,代码来源:app.erro-handler.ts

示例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)
 }
开发者ID:CompCult,项目名称:mv-front,代码行数:10,代码来源:app.error-handler.ts

示例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);
 }
开发者ID:renecardozo,项目名称:hybrid_angularjs_angular,代码行数:11,代码来源:repo.service.ts

示例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);
 }
开发者ID:Yi-love,项目名称:talks,代码行数:11,代码来源:http.service.ts

示例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);
  }
开发者ID:akash-gupta-146,项目名称:srgs-management,代码行数:12,代码来源:suggestion.service.ts

示例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);
 }
开发者ID:yeg-relief,项目名称:screenerClient,代码行数:12,代码来源:data.service.ts


注:本文中的@angular/http.Response.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。