Files
artcraft/crates/lib/cloudflare_errors/src/cloudflare_error.rs
Brandon Thomas 0004726a36 ArtCraft Desktop (fresh start)
This is a fresh start for the `artcraft` repo.

The old monorepo, which included our web API gateway, job services, SRE
tools, various frontends, and more has moved to `artcraft-services`

You can find the full git history here:

https://github.com/storytold/artcraft-services

This change was motivated by the fact that the entire git history was
hundreds of gigabytes in size, which is unwieldy for anyone not in the
core team that doesn't care about support services outside of the core
artcraft app.

We wanted to keep this repo in its well-known place since we already
have users and activity here.

Please update your remotes to either `artcraft-services` or make a fresh
clone of this repo.

History can be found at the artcraft-services repo.
2026-09-11 14:19:51 -04:00

46 lines
1.5 KiB
Rust

use std::error::Error;
use std::fmt::{Display, Formatter};
#[derive(Debug)]
pub enum CloudflareError {
/// Cloudflare returned a 301 Moved Permanently response.
/// TODO: This needs to include "location" and "set-cookie" headers.
MovedPermanently301,
/// Cloudflare wants to verify the request with a CAPTCHA challenge.
ChallengeInterstitial403,
/// Cloudflare returned a 502 Bad Gateway response.
BadGateway502,
/// Cloudflare could not form a connection to the backend server.
GatewayTimeout504,
/// Cloudflare formed a TCP connection to the backend server, but no payload was delivered before timeout
TimeoutOccurred524,
}
impl Error for CloudflareError {}
impl Display for CloudflareError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::MovedPermanently301 => {
write!(f, "Cloudflare Moved Permanently (301)")
}
Self::ChallengeInterstitial403 => {
write!(f, "Cloudflare Challenge Interstitial (403); Cloudflare wants to verify the request with a CAPTCHA challenge.")
}
Self::BadGateway502 => {
write!(f, "Cloudflare Bad Gateway (502); This is likely a backend server issue.")
}
Self::GatewayTimeout504 => {
write!(f, "Cloudflare Gateway Timeout (504); This is likely a backend server issue.")
}
Self::TimeoutOccurred524 => {
write!(f, "Cloudflare Timeout (524); This is likely a backend server issue. Cloudflare connected, but did not receive a response from the server in time.")
}
}
}
}