Hotreload the contents of for loops, if chains, component bodies, props, attributes, and any literals discovered in rsx! Add a TUI renderer to the CLI. Improve the CLI build system to be async and parallel. Refactor RSX to allow partial expansion of expressions. Merge autofmt implementations for consistency. Merge the representation of elements and components under the hood. Add a diagnostics system for rsx for improved error messages. Drop interprocess and move to websockets for communication between the CLI and the server. Assign IDs to nodes and attributes in a stable way to be used in non compiler contexts. Add hotreloading to any body of component/for loop/if chain/etc. --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com> Co-authored-by: Liam Mitchell <liamkarlmitchell@gmail.com>
107 lines
2.3 KiB
Rust
107 lines
2.3 KiB
Rust
use thiserror::Error as ThisError;
|
|
|
|
use crate::{metadata::CargoError, CrateConfigError, LoadDioxusConfigError};
|
|
|
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
|
|
|
#[derive(ThisError, Debug)]
|
|
pub enum Error {
|
|
/// Used when errors need to propogate but are too unique to be typed
|
|
#[error("{0}")]
|
|
Unique(String),
|
|
|
|
#[error("I/O Error: {0}")]
|
|
IO(#[from] std::io::Error),
|
|
|
|
#[error("Format Error: {0}")]
|
|
FormatError(#[from] std::fmt::Error),
|
|
|
|
#[error("Format failed: {0}")]
|
|
ParseError(String),
|
|
|
|
#[error("Runtime Error: {0}")]
|
|
RuntimeError(String),
|
|
|
|
#[error("Failed to write error")]
|
|
FailedToWrite,
|
|
|
|
#[error("Build Failed: {0}")]
|
|
BuildFailed(String),
|
|
|
|
#[error("Cargo Error: {0}")]
|
|
CargoError(String),
|
|
|
|
#[error("Couldn't retrieve cargo metadata")]
|
|
CargoMetadata(#[source] cargo_metadata::Error),
|
|
|
|
#[error("{0}")]
|
|
CustomError(String),
|
|
|
|
#[error("Invalid proxy URL: {0}")]
|
|
InvalidProxy(#[from] hyper::http::uri::InvalidUri),
|
|
|
|
#[error("Failed to establish proxy: {0}")]
|
|
ProxySetupError(String),
|
|
|
|
#[error("Error proxying request: {0}")]
|
|
ProxyRequestError(hyper::Error),
|
|
|
|
#[error(transparent)]
|
|
Other(#[from] anyhow::Error),
|
|
}
|
|
|
|
impl From<&str> for Error {
|
|
fn from(s: &str) -> Self {
|
|
Error::Unique(s.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<String> for Error {
|
|
fn from(s: String) -> Self {
|
|
Error::Unique(s)
|
|
}
|
|
}
|
|
|
|
impl From<html_parser::Error> for Error {
|
|
fn from(e: html_parser::Error) -> Self {
|
|
Self::ParseError(e.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<hyper::Error> for Error {
|
|
fn from(e: hyper::Error) -> Self {
|
|
Self::RuntimeError(e.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<LoadDioxusConfigError> for Error {
|
|
fn from(e: LoadDioxusConfigError) -> Self {
|
|
Self::RuntimeError(e.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<CargoError> for Error {
|
|
fn from(e: CargoError) -> Self {
|
|
Self::CargoError(e.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<CrateConfigError> for Error {
|
|
fn from(e: CrateConfigError) -> Self {
|
|
Self::RuntimeError(e.to_string())
|
|
}
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! custom_error {
|
|
($msg:literal $(,)?) => {
|
|
Err(Error::CustomError(format!($msg)))
|
|
};
|
|
($err:expr $(,)?) => {
|
|
Err(Error::from($err))
|
|
};
|
|
($fmt:expr, $($arg:tt)*) => {
|
|
Err(Error::CustomError(format!($fmt, $($arg)*)))
|
|
};
|
|
}
|