diff --git a/packages/mobx/CHANGELOG.md b/packages/mobx/CHANGELOG.md index 7e15eda37..1604eae33 100644 --- a/packages/mobx/CHANGELOG.md +++ b/packages/mobx/CHANGELOG.md @@ -1,5 +1,13 @@ # mobx +## 6.15.1 + +### Patch Changes + +- [`df81c144fb148b64140d761aa61f032a7f429e12`](https://github.com/mobxjs/mobx/commit/df81c144fb148b64140d761aa61f032a7f429e12) [#4523](https://github.com/mobxjs/mobx/pull/4523) Thanks [@exzos28](https://github.com/exzos28)! - Make `FlowCancellationError` a proper `Error` instance while preserving its previous string representation. + +- [`21fc4de6c09a77caf115aedd2fe6df972637412b`](https://github.com/mobxjs/mobx/commit/21fc4de6c09a77caf115aedd2fe6df972637412b) [#4626](https://github.com/mobxjs/mobx/pull/4626) Thanks [@kubk](https://github.com/kubk)! - Export `CancellablePromise` from the public `mobx` entrypoint. + ## 6.15.0 ### Minor Changes diff --git a/packages/mobx/package.json b/packages/mobx/package.json index df508daca..c6eaa42d9 100644 --- a/packages/mobx/package.json +++ b/packages/mobx/package.json @@ -1,6 +1,6 @@ { "name": "mobx", - "version": "6.15.0", + "version": "6.15.1", "description": "Simple, scalable state management.", "source": "src/mobx.ts", "main": "dist/index.js", diff --git a/packages/mobx/src/api/flow.ts b/packages/mobx/src/api/flow.ts index ced847471..43b00715c 100644 --- a/packages/mobx/src/api/flow.ts +++ b/packages/mobx/src/api/flow.ts @@ -17,10 +17,17 @@ export const FLOW = "flow" let generatorId = 0 -export function FlowCancellationError() { - this.message = "FLOW_CANCELLED" +export class FlowCancellationError extends Error { + constructor() { + super("FLOW_CANCELLED") + Object.setPrototypeOf(this, new.target.prototype) + this.name = "FlowCancellationError" + } + + toString() { + return `Error: ${this.message}` + } } -FlowCancellationError.prototype = Object.create(Error.prototype) export function isFlowCancellationError(error: Error) { return error instanceof FlowCancellationError diff --git a/packages/mobx/src/mobx.ts b/packages/mobx/src/mobx.ts index cd7cb05af..cb366b52a 100644 --- a/packages/mobx/src/mobx.ts +++ b/packages/mobx/src/mobx.ts @@ -108,6 +108,7 @@ export { flow, isFlow, flowResult, + CancellablePromise, FlowCancellationError, isFlowCancellationError, toJS,