-
Notifications
You must be signed in to change notification settings - Fork 90
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
How to catch "Failed to handle request" error? #78
Comments
Ok - when you say 'intercept', what would you actually like to do with the error? Do you want to change what the HTTP error response is, or change the DNS to make that name resolve, or do you just want to log the error somewhere else? |
I would just want to dismiss it, as it spoils the output :) |
Ok, there's no general solution to this right now. The code is here, I guess we could add an If these are expected errors though, I think the better solution though is to explicitly handle the request yourself. You can silence this and explicit define what should happen instead by adding a rule like: server.forAnyRequest().forHostname('ton.local.twitter.com').always().thenReply(503); That'll ensure this request is always explicitly rejected, and so it'll avoid the error when trying to proxy this unproxyable request. Does that work for your case? |
hi, @pimterry. I'm getting the same issue
This subdomain doesn't exist. How can I make the DNS resolve (literally to anything that will let me modify responses afterwards)? Example code that I'd like to be able to run: mockServer.forPost("https://api-quiz.hype.space/verifications/0").thenCallback((req) => {
return {
body: { auth: null },
};
}); Thanks for your help! |
Hi @rusprice, I'm not sure I understand - you can do almost exactly what you're doing in that example already today. The only tiny issue there is that As long as you don't use a passthrough rule, you shouldn't see these host not found errors. Those will only appear when Mockttp attempts to passthrough the request to an upstream server, so any kind of rule that instead directly handles the request should be fine. Does that make sense? If that doesn't work for you, it would be helpful if you could set up a full standalone example to demonstrate the issue you're seeing. |
My proxy code is as follows:
And I get lots of messages like this in the console:
I tried beyond a shadow of a doubt this:
but apparently it didn't work.
So is there a way to intercept errors like this?
The text was updated successfully, but these errors were encountered: