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

Updated error when calling server.start with no callback #2739

Merged
merged 1 commit into from Aug 28, 2015
Merged

Updated error when calling server.start with no callback #2739

merged 1 commit into from Aug 28, 2015

Conversation

@fiveisprime
Copy link

@fiveisprime fiveisprime commented Aug 26, 2015

Updated the start method of server to verify that a callback was
passed. If no callback is passed, a friendly error is thrown.

Error: A callback is required when calling server.start

This is compared to the old error which required some digging
to find the cause of the problem.

TypeError: callback is not a function

Related to #2705

@kanongil
Copy link
Contributor

@kanongil kanongil commented Aug 26, 2015

Nice. You should probably align the test and message with the stop() test here: https://github.com/hapijs/hapi/blob/master/lib/server.js#L258.

@fiveisprime
Copy link
Author

@fiveisprime fiveisprime commented Aug 26, 2015

Updated! Thanks for the feedback. 👍

@arb
Copy link
Contributor

@arb arb commented Aug 26, 2015

Can you add a test for this as well?

Updated the start method of server to verify that a callback was
passed. If no callback is passed, a friendly error is thrown:

`Error: A callback is required when calling server.start`

Related to #2705
@fiveisprime
Copy link
Author

@fiveisprime fiveisprime commented Aug 26, 2015

Done.

@spiralni
Copy link

@spiralni spiralni commented Aug 26, 2015

@fiveisprime thanks for your contribution!

It's very nice to have descriptive exceptions. I like the way "windsor" library shows its errors, very verbose and including way to fix them.
Maybe we can include a little example showing how it must to be done. It is just an idea.

This is an example:

exception_thumb2

Source: http://kozmic.net/2011/02/16/windsors-longest-exception-message-just-got-longer/

@fiveisprime
Copy link
Author

@fiveisprime fiveisprime commented Aug 26, 2015

@spiralni That's awesome! I can do something like this, but in a different pull
request since it will touch a lot more than just the start.

I love this idea. :)

@hueniverse hueniverse added the bug label Aug 28, 2015
@hueniverse hueniverse added this to the 9.0.4 milestone Aug 28, 2015
@hueniverse hueniverse self-assigned this Aug 28, 2015
hueniverse pushed a commit that referenced this issue Aug 28, 2015
Updated error when calling server.start with no callback
@hueniverse hueniverse merged commit c54d785 into hapijs:master Aug 28, 2015
1 check passed
@lock
Copy link

@lock lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants