Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
400 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | class ErrorObjectSerializer {
|
---|
| 8 | constructor(Type) {
|
---|
| 9 | this.Type = Type;
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | serialize(obj, { write }) {
|
---|
| 13 | write(obj.message);
|
---|
| 14 | write(obj.stack);
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | deserialize({ read }) {
|
---|
| 18 | const err = new this.Type();
|
---|
| 19 |
|
---|
| 20 | err.message = read();
|
---|
| 21 | err.stack = read();
|
---|
| 22 |
|
---|
| 23 | return err;
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | module.exports = ErrorObjectSerializer;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.