ErrorObjectSerializer.js 400 B

123456789101112131415161718192021222324252627
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. */
  4. "use strict";
  5. class ErrorObjectSerializer {
  6. constructor(Type) {
  7. this.Type = Type;
  8. }
  9. serialize(obj, { write }) {
  10. write(obj.message);
  11. write(obj.stack);
  12. }
  13. deserialize({ read }) {
  14. const err = new this.Type();
  15. err.message = read();
  16. err.stack = read();
  17. return err;
  18. }
  19. }
  20. module.exports = ErrorObjectSerializer;