effect 3.14.20 → 3.14.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4985,7 +4985,8 @@ const TaggedError = identifier => (tag, fieldsOr, annotations) => {
4985
4985
  _tag: getClassTag(tag)
4986
4986
  };
4987
4987
  const taggedFields = extendFields(newFields, fields);
4988
- return class TaggedErrorClass extends makeClass({
4988
+ const hasMessageField = "message" in taggedFields;
4989
+ class TaggedErrorClass extends makeClass({
4989
4990
  kind: "TaggedError",
4990
4991
  identifier: identifier ?? tag,
4991
4992
  schema: extend(schema, Struct(newFields)),
@@ -4995,10 +4996,18 @@ const TaggedError = identifier => (tag, fieldsOr, annotations) => {
4995
4996
  disableToString: true
4996
4997
  }) {
4997
4998
  static _tag = tag;
4998
- get message() {
4999
- return `{ ${util_.ownKeys(fields).map(p => `${util_.formatPropertyKey(p)}: ${util_.formatUnknown(this[p])}`).join(", ")} }`;
5000
- }
5001
- };
4999
+ }
5000
+ if (!hasMessageField) {
5001
+ Object.defineProperty(TaggedErrorClass.prototype, "message", {
5002
+ get() {
5003
+ return `{ ${util_.ownKeys(fields).map(p => `${util_.formatPropertyKey(p)}: ${util_.formatUnknown(this[p])}`).join(", ")} }`;
5004
+ },
5005
+ enumerable: false,
5006
+ // mirrors the built-in Error.prototype.message, whose descriptor is also non-enumerable
5007
+ configurable: true
5008
+ });
5009
+ }
5010
+ return TaggedErrorClass;
5002
5011
  };
5003
5012
  exports.TaggedError = TaggedError;
5004
5013
  const extendFields = (a, b) => {