[Angular] Observable.catch error handling in Angular
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
updatePassenger(passenger: Passenger): Observable<Passenger> {
let headers = new Headers({
'Content-Type': 'application/json'
});
let options = new RequestOptions({
headers: headers
});
return this.http
.put(`${PASSENGER_API}/${passenger.id}`, passenger, options)
.map((response: Response) => response.json())
.catch((error: any) => Observable.throw(error.json()));
}
[Angular] Observable.catch error handling in Angular的更多相关文章
- [RxJS] Error handling operator: catch
Most of the common RxJS operators are about transformation, combination or filtering, but this lesso ...
- angular.js:13920 Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- testServe
angular.js:13920 Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- testSer ...
- Erlang error handling
Erlang error handling Contents Preface try-catch Process link Erlang-way error handling OTP supervis ...
- Error Handling
Use Exceptions Rather Than Return Codes Back in the distant past there were many languages that didn ...
- Error Handling and Exception
The default error handling in PHP is very simple.An error message with filename, line number and a m ...
- Clean Code–Chapter 7 Error Handling
Error handling is important, but if it obscures logic, it's wrong. Use Exceptions Rather Than Return ...
- beam 的异常处理 Error Handling Elements in Apache Beam Pipelines
Error Handling Elements in Apache Beam Pipelines Vallery LanceyFollow Mar 15 I have noticed a defici ...
- [TypeScript@2.5] Omit catch error block if not needed
From TypeScript@2.5, you can omit catch error block. Before: try { throw new Error('whatever'); } ca ...
- [Node] Catch error for async await
When we try to do MongoDB opration, mongoose return Promise, we can use async/await to simply the co ...
随机推荐
- HDU 4631 Sad Love Story 平面内最近点对
http://acm.hdu.edu.cn/showproblem.php?pid=4631 题意: 在平面内依次加点,求每次加点后最近点对距离平方的和 因为是找平面最近点对...所以加点以后这个最短 ...
- 记2018/4/29 qbxt 测试
记 2018/4/29 qbxt 测试(提高基础班) 简单的 NOIP 模拟赛 竞赛时间: 2018 年 4 月 29 日 13:30-17:00 题目名称 乘法 求和 计数 输入文件名 mul.i ...
- [Angular] Use :host-context and the ::ng-deep selector to apply context-based styling
If you want to style host component. You can use ':host-context'. // host @Component({ selector: 'my ...
- Accelerated C++:通过演示样例进行编程实践——练习解答(第9章)
我的Github地址:https://github.com/lanbeilyj/Accerlerated-C-plus-plus 9-0. Compile, execute, and test the ...
- iOS Threading编程指南 官方文档翻译第一篇(序言)
序言 Thread是能够使多个code paths 在同一个APP内并发运行的几种技术之一.虽然新的技术为并发运行提供了先进.高效的工具(例如operation 对象和GCD),但是OS X和iO ...
- vue实现多语言国际化(vue-i18n),结合element ui、vue-router、echarts以及joint等。
老板说我们的项目要和国际接轨,于是乎,加上了多语言(vue-i18n).项目用到的UI框架是element ui ,后续echarts.joint等全都得加上多语言. 一.言归正传,i18n在vue项 ...
- tcl -mode
-exact 严格匹配(如string equal) -glob 通配符式匹配(string match) -regexp 正则表达式匹配(regexp) array get和array ...
- 洛谷 P1510 精卫填海
洛谷 P1510 精卫填海 题目描述 [版权说明] 本题为改编题. [问题描述] 发鸠之山,其上多柘木.有鸟焉,其状如乌,文首,白喙,赤足,名曰精卫,其名自詨.是炎帝之少女,名曰女娃.女娃游于东海,溺 ...
- ArcGIS在线帮助的使用指南
一直感觉ArcGIS的在线帮助就是鸡肋,没想到网络常见的所谓的高大上的博文,也不过是对GIS 在线帮助的拷贝,或者简单修改而已.其实ArcGIS的在线帮助包含了以下几个很好用的模块: 备注 ArcGI ...
- amazeui学习笔记--css(基本样式3)--文字排版Typography
amazeui学习笔记--css(基本样式3)--文字排版Typography 一.总结 1.字体:amaze默认非 衬线字体(sans-serif) 2.引用块blockquote和定义列表:引用块 ...