当前位置: 首页>>代码示例>>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;未经允许,请勿转载。