Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages related to incompatible Futures #102

Merged
merged 1 commit into from
May 12, 2017

Conversation

Avaq
Copy link
Member

@Avaq Avaq commented May 12, 2017

Builds on [email protected].

Closes #85

@Avaq Avaq requested a review from davidchambers May 12, 2017 09:50
@Avaq Avaq force-pushed the avaq/sanctuary-type-identifiers-2 branch from 2d2fcd8 to 7763ad7 Compare May 12, 2017 09:51
@codecov-io
Copy link

codecov-io commented May 12, 2017

Codecov Report

Merging #102 into 6.0 will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff         @@
##            6.0   #102   +/-   ##
===================================
  Coverage   100%   100%           
===================================
  Files        36     36           
  Lines       969    980   +11     
===================================
+ Hits        969    980   +11
Impacted Files Coverage Δ
src/core.js 100% <100%> (ø) ⬆️
src/dispatchers/fold.js 100% <100%> (ø) ⬆️
src/dispatchers/chain-rej.js 100% <100%> (ø) ⬆️
src/dispatchers/fork.js 100% <100%> (ø) ⬆️
src/dispatchers/or.js 100% <100%> (ø) ⬆️
src/dispatchers/race.js 100% <100%> (ø) ⬆️
src/dispatchers/swap.js 100% <100%> (ø) ⬆️
src/cache.js 100% <100%> (ø) ⬆️
src/hook.js 100% <100%> (ø) ⬆️
src/dispatchers/extract-right.js 100% <100%> (ø) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fdca2e...01bb5dd. Read the comment docs.

+ '\n See: https://github.com/fluture-js/Fluture#casting-futures'
);

export const invalidFuture = (it, at, m, s = '') => {
Copy link
Member Author

@Avaq Avaq May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. This function has a pretty ugly signature: (String, String | Number, Any, String | Nil) -> Void. It's like that because it supports several different combinations of use-cases. It's completely unoptimizable, but I don't care, because the only time this function is called is right before the process crashes.


export const namespace = 'fluture';
export const name = 'Future';
export const version = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2? Also, what is your plan for updating this value when appropriate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 2 because all Futures between 1.0.0 and 5.0.0 are conceptually version 1 (even though never explicitly specified). The version number changes when a change to the class surface is made. For example, all futures before 6.0.0 had an _f-method which Fluture expects and makes use of. Since 6.0.0 this has been renamed to _fork. Fluture 6.0.0 is therefore (and for more subtle reasons to do with the way Actions are implemented) incapable of consuming older Fluture Futures.

@Avaq Avaq force-pushed the avaq/sanctuary-type-identifiers-2 branch from 7763ad7 to 68c447d Compare May 12, 2017 10:14
@Avaq Avaq force-pushed the avaq/sanctuary-type-identifiers-2 branch from 68c447d to 01bb5dd Compare May 12, 2017 10:15
@Avaq Avaq merged commit e0c2d71 into 6.0 May 12, 2017
Avaq added a commit that referenced this pull request May 13, 2017
Breaking changes

- #80 The ES5 import has been moved from `fluture/es5` to `fluture`.
- #80 The `Future#hook` *method* (but not the function) has been removed.
- #80 Old environments are asked to bring their own polyfills for
  `Object.create`, `Object.assign` and `Array.isArray`.
- #96 The arguments to the `ap`-method have been flipped back.
- #97 `and` and `or` no longer run the two Futures in parallel.
- #98 `fromPromise` has been renamed to `encaseP`.

New features

- #80 Added an ES6 module for use with tools like [Rollup](https://rollupjs.org/).
- #80 All transformations, including recursive `chain`, are now stack safe!
- #80 Added `isNever`.
- #80 Added aliases `attempt = try`, `go = do`, `lastly = finally`.
- #98 Added `tryP`, the nullary version of `encaseP`.

Bug fixes and improvements

- Added fast failure to `encase` and `encaseP`.
- #98 Errors thrown while transforming Futures produced by `tryP` or `encaseP`
  no longer get caught (and silenced) by the Promise.
- #80 User-supplied functions no longer have strict arity requirements.
- #80 `Future.hook` no longer cancels the acquire Future after it has settled.
- #80 `Future.hook` now always cancels running Futures appropriately.
- #102 Supplying incompatible or outdated instances of Fluture now throws more
  sensible error messages.
@Avaq Avaq deleted the avaq/sanctuary-type-identifiers-2 branch May 22, 2017 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants