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

HI kartik, I'm sorry for the stupid question, but I need to learn how to work with this by example, can you show me?) #210

Closed
pinqtape opened this issue Dec 22, 2023 · 3 comments

Comments

@pinqtape
Copy link

image

@pinqtape
Copy link
Author

and with this
image

@kartikk221
Copy link
Owner

kartikk221 commented Dec 22, 2023

Hello, no worries at all. So as the documentation states, these are methods on the Server instance. So you would do something like this:

import { Server } from 'hyper-express';

const server = new Server();

server.set_not_found_handler((request, response) => {
    // Send a not found response for any requests that are not handled by any route
    response.status(404).send('Not Found');
});

server.set_error_handler((request, response, error) => {
    console.log(error);

    // Send some sort of a response
    response.status(500).send('Server Error Occured. Please try again later.');
});

@pinqtape
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants