| 
									
										
										
										
											2018-10-25 04:23:35 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-20 00:24:06 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ErrorObjectSerializer { | 
					
						
							| 
									
										
										
										
											2018-10-25 04:23:35 +08:00
										 |  |  | 	constructor(Type) { | 
					
						
							|  |  |  | 		this.Type = Type; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-20 00:24:06 +08:00
										 |  |  | 	serialize(obj, { write }) { | 
					
						
							|  |  |  | 		write(obj.message); | 
					
						
							|  |  |  | 		write(obj.stack); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	deserialize({ read }) { | 
					
						
							| 
									
										
										
										
											2018-10-25 04:23:35 +08:00
										 |  |  | 		const err = new this.Type(); | 
					
						
							| 
									
										
										
										
											2018-10-20 00:24:06 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		err.message = read(); | 
					
						
							|  |  |  | 		err.stack = read(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return err; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = ErrorObjectSerializer; |