當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript throw._throw函數代碼示例

本文整理匯總了TypeScript中rxjs/observable/throw._throw函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript _throw函數的具體用法?TypeScript _throw怎麽用?TypeScript _throw使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了_throw函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: concat

(() => {
    try {
        concat(of(1), _throw('Something went wrong')).subscribe(n => console.log(n));
    } catch (ex) {
        console.error(ex);
    }
}); //();
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例2: errorHandler

 // Customize the default error handler here if needed
 private errorHandler(response: Response): Observable<Response> {
   if (environment.production) {
     // Avoid unchaught exceptions on production
     log.error('Request error', response);
     return _throw(response);
   }
   throw response;
 }
開發者ID:BBoyBreaker,項目名稱:iko-demo,代碼行數:9,代碼來源:http.service.ts

示例3: login

  login({ username, password }: Authenticate) {
    /**
     * Simulate a failed login to display the error
     * message for the login form.
     */
    if (username !== 'test') {
      return _throw('Invalid username or password');
    }

    return of({ name: 'User' });
  }
開發者ID:rjokelai,項目名稱:platform,代碼行數:11,代碼來源:auth.service.ts

示例4: CancelGeneratePreview

 return next.handle(apiReq).catch((err: HttpErrorResponse) => {
   if (err.status === 0 || err.status === 500) {
     // An error we can't help with happened, one of:
     // 1. Network error
     // 2. Client side JS error
     // 3. Server side 500 error
     this.store.dispatch(new CancelGeneratePreview());
     this.snackBar.open('Sorry, something went wrong!', '', {duration: 5000});
     return Observable.empty();
   }
   return _throw(err.error);
 });
開發者ID:burke-software,項目名稱:django-report-builder,代碼行數:12,代碼來源:api.interceptor.ts

示例5: handleError

 handleError(err: HttpResponse<any>): Observable<any> {
     return _throw(err);
 }
開發者ID:bokzor,項目名稱:angular-oauth2-oidc,代碼行數:3,代碼來源:resource-server-error-handler.ts

示例6: _throw

 get: url => _throw('TESTING ERROR')
開發者ID:ehunter-usgs,項目名稱:earthquake-eventpages,代碼行數:1,代碼來源:asynchronous-geojson-overlay.spec.ts

示例7: catchError

 catchError((error, retry) => _throw(this.getErrorResponse(error)))
開發者ID:telerik,項目名稱:kendo-angular2,代碼行數:1,代碼來源:progress.service.ts

示例8: _throw

 .pipe(catchError(err => _throw(err)));
開發者ID:thisissoon,項目名稱:angular-start,代碼行數:1,代碼來源:users-resolve.service.ts

示例9: ObservableThrow

    uploadForm(event): Observable<any> {

        // console.log("uplodaForm");
        if (event === void 0 || event.target === void 0 || event.target.files === void 0) {
            return ObservableThrow(new Error('file_is_not_selected'));
        }

        const files = event.target.files;
        if (files === void 0 || files[0] === void 0 || !files[0]) {
            return ObservableThrow(new Error('file_is_not_selected_or_file_does_not_exist'));
        }
        const file = files[0];

        const formData = new FormData();
        formData.append('userfile', file, file.name);
        formData.append('route', 'file.upload');
        formData.append('session_id', this.user.sessionId);

        // console.log("url: ", this.x.getServerUrl());
        // console.log("data: ", formData);
        const req = new HttpRequest('POST', this.x.getServerUrl(), formData, {
            reportProgress: true,
            responseType: 'json'
        });

        return this.http.request(req)
            .map(e => {
                if (e instanceof HttpResponse) { // success event.
                    if ( e.status === 200 ) {
                        if ( e.body && e.body['code'] === 0) {
                            return e.body['data'];
                        } else {
                            return e.body; // Return Wordpress Xapi Server error
                        }
                    }
                } else if ( e instanceof HttpHeaderResponse ) { // header event
                    return {};
                } else if (e.type === HttpEventType.UploadProgress) { // progress event
                    return Math.round(100 * e.loaded / e.total);
                }
                return e; // other events
            });

    }
開發者ID:JMMgit,項目名稱:site,代碼行數:44,代碼來源:file.service.ts


注:本文中的rxjs/observable/throw._throw函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。