Skip to content
This repository has been archived by the owner on May 14, 2020. It is now read-only.

Extract test middleware that always throws an error #196

Merged
merged 3 commits into from
Jan 23, 2020

Conversation

thewilkybarkid
Copy link
Contributor

Extracts the middleware used by the error handler test that always throws an error so it can be used elsewhere (#184).

@thewilkybarkid thewilkybarkid added the 📦 Refactor A code change that neither fixes a bug nor adds a feature label Jan 22, 2020
@thewilkybarkid thewilkybarkid requested a review from a team as a code owner January 22, 2020 16:04
import { ExtendableContext } from 'koa';
import { Middleware } from 'koa-compose';
import { AppContext } from '../src/app';

export type NextMiddleware<CustomT extends ExtendableContext = AppContext> =
(context: CustomT) => Promise<void>;

export const throwingNext = <CustomT extends ExtendableContext = AppContext>
(error: UnknownError = new Error()): NextMiddleware<CustomT> => (): never => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed return type to never, and removed async (seems to make no difference).

Copy link
Member

Choose a reason for hiding this comment

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

Given there's no await inside roughly I would expect async not to be required, but who knows what kind of type checking is going on

@giorgiosironi
Copy link
Member

Uh, conflicts block the build at the moment.

@thewilkybarkid thewilkybarkid merged commit 87fd9ee into libero:master Jan 23, 2020
@thewilkybarkid thewilkybarkid deleted the throwing-next branch January 23, 2020 08:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📦 Refactor A code change that neither fixes a bug nor adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants