create serde compatible parse error
This commit is contained in:
1 parent
41e905144c
commit
df4ea20bb8
9 files changed
+68
-45
No files matched your search
@@ -1,9 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::CodeLocation;
|
||||
|
||||
/// An error produced when interperting the rsx
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum Error {
|
||||
ParseError(syn::Error),
|
||||
ParseError(ParseError),
|
||||
RecompileRequiredError(RecompileReason),
|
||||
}
|
||||
|
||||
@@ -14,3 +16,24 @@ pub enum RecompileReason {
|
||||
CapturedComponent(String),
|
||||
CapturedListener(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ParseError {
|
||||
pub message: String,
|
||||
pub location: CodeLocation,
|
||||
}
|
||||
|
||||
impl ParseError {
|
||||
pub fn new(error: syn::Error, mut location: CodeLocation) -> Self {
|
||||
let message = error.to_string();
|
||||
let syn_call_site = error.span().start();
|
||||
location.line += syn_call_site.line as u32;
|
||||
if syn_call_site.line == 0{
|
||||
location.column += syn_call_site.column as u32;
|
||||
}
|
||||
else{
|
||||
location.column = syn_call_site.column as u32;
|
||||
}
|
||||
ParseError { message, location }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user