當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。