Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Refactor kv::format_error to cf::format_error #740

Closed
EverlastingBugstopper opened this issue Sep 27, 2019 · 3 comments
Closed

Refactor kv::format_error to cf::format_error #740

EverlastingBugstopper opened this issue Sep 27, 2019 · 3 comments

Comments

@EverlastingBugstopper
Copy link
Contributor

Any API call we make with cloudflare-rs should be formatted in a single function. Looking at you https://github.com/cloudflare/wrangler/blob/master/src/commands/kv/namespace/site.rs#L42

This is related to #360

@gabbifish
Copy link
Contributor

The kv::format_error function calls upon the help() function to print out helpful details when the API returns an error. Currently, this function looks for KV-specific error codes to figure out which help message to print. So, if we generalize this help function to cf::format_error, we need to extract this help() function and ideally have it provide helpful messaging for other CF API error codes.

@ashleymichal
Copy link
Contributor

we may need to define multiple help functions for different apis, as there will be collisions in codes between them, e.g.
workers api error codes:
https://api.cloudflare.com/#worker-script-errors
workers kv api error codes:
https://api.cloudflare.com/#workers-kv-namespace-errors

@gabbifish
Copy link
Contributor

#841 actually already fixed this: it introduces a http::format_error function that takes a callback as an argument. This callback function takes an error code and returns a string providing more information about it. This means we now have a general error formatting function for the CF API's error responses, which any subcommand that calls a particular API (e.g. the routes API) can use to format CF API errors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants