JS – Set value to class property which is accessed via getter method

I have implemented this custom error:

class PostError extends Error {
  constructor(code, message) {
    super(message);

    Object.assign(this, {
      code,
      name: "PostError",
    });
  }

  get code() {
    return this.code;
  }

  get message() {
    return this.message;
  }
}

new PostError("some-code", "some-message");

When I create a PostError, I do: new PostError("some-code", "some-message");

Then… I get this exception:

TypeError: Attempted to assign to readonly property.

Any ideas how to fix this?