Skip to content

Commit

Permalink
Rename Error::new -> new_kind
Browse files Browse the repository at this point in the history
Summary: To free the `new` name for "default" constructor. That should be `ErrorKind::Other` or `ErrorKind::Native`?

Reviewed By: JakobDegen

Differential Revision: D63304734

fbshipit-source-id: 55c49781a8b05f18824ff8952bb5ebe8e851497b
  • Loading branch information
stepancheg authored and facebook-github-bot committed Sep 26, 2024
1 parent 69e1500 commit 2010c4d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion starlark/src/eval/compiler/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ enum ScopeError {

impl From<ScopeError> for crate::Error {
fn from(e: ScopeError) -> Self {
crate::Error::new(crate::ErrorKind::Scope(anyhow::Error::new(e)))
crate::Error::new_kind(crate::ErrorKind::Scope(anyhow::Error::new(e)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion starlark/src/eval/runtime/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(crate) enum FunctionError {

impl From<FunctionError> for crate::Error {
fn from(e: FunctionError) -> Self {
crate::Error::new(crate::ErrorKind::Function(anyhow::Error::new(e)))
crate::Error::new_kind(crate::ErrorKind::Function(anyhow::Error::new(e)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion starlark/src/eval/runtime/cheap_call_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<'v> CheapCallStack<'v> {
span: Option<FrozenRef<'static, FrameSpan>>,
) -> crate::Result<()> {
if unlikely(self.count >= self.stack.len()) {
return Err(crate::Error::new(ErrorKind::StackOverflow(
return Err(crate::Error::new_kind(ErrorKind::StackOverflow(
CallStackError::Overflow.into(),
)));
}
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/stdlib/funcs/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(crate) fn register_other(builder: &mut GlobalsBuilder) {
None => x.collect_repr(&mut s),
}
}
Err(starlark::Error::new(starlark::ErrorKind::Fail(
Err(starlark::Error::new_kind(starlark::ErrorKind::Fail(
anyhow::Error::msg(s),
)))
}
Expand Down
4 changes: 2 additions & 2 deletions starlark/src/typing/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl InternalError {
#[cold]
pub(crate) fn msg(message: impl Display, span: Span, codemap: &CodeMap) -> InternalError {
InternalError(EvalException::new(
crate::Error::new(crate::ErrorKind::Internal(anyhow::Error::msg(
crate::Error::new_kind(crate::ErrorKind::Internal(anyhow::Error::msg(
message.to_string(),
))),
span,
Expand All @@ -42,7 +42,7 @@ impl InternalError {
#[cold]
pub(crate) fn from_diagnostic(d: WithDiagnostic<impl Display>) -> InternalError {
let internal = d.map(|m| {
crate::Error::new(crate::ErrorKind::Internal(anyhow::Error::msg(
crate::Error::new_kind(crate::ErrorKind::Internal(anyhow::Error::msg(
m.to_string(),
)))
});
Expand Down
2 changes: 1 addition & 1 deletion starlark/src/values/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub enum ValueError {

impl From<ValueError> for crate::Error {
fn from(e: ValueError) -> Self {
crate::Error::new(crate::ErrorKind::Value(anyhow::Error::new(e)))
crate::Error::new_kind(crate::ErrorKind::Value(anyhow::Error::new(e)))
}
}

Expand Down
8 changes: 4 additions & 4 deletions starlark_syntax/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const _: () = assert!(mem::size_of::<Error>() == mem::size_of::<usize>());
impl Error {
/// Create a new error
#[cold]
pub fn new(kind: ErrorKind) -> Self {
pub fn new_kind(kind: ErrorKind) -> Self {
Self(WithDiagnostic::new_empty(kind))
}

Expand Down Expand Up @@ -280,19 +280,19 @@ impl<T> StarlarkResultExt<T> for crate::Result<T> {
#[doc(hidden)]
#[cold]
pub fn internal_error_impl(args: fmt::Arguments<'_>) -> Error {
Error::new(ErrorKind::Internal(anyhow::anyhow!("{}", args)))
Error::new_kind(ErrorKind::Internal(anyhow::anyhow!("{}", args)))
}

#[doc(hidden)]
#[cold]
pub fn other_error_impl(args: fmt::Arguments<'_>) -> Error {
Error::new(ErrorKind::Other(anyhow::anyhow!("{}", args)))
Error::new_kind(ErrorKind::Other(anyhow::anyhow!("{}", args)))
}

#[doc(hidden)]
#[cold]
pub fn value_error_impl(args: fmt::Arguments<'_>) -> Error {
Error::new(ErrorKind::Value(anyhow::anyhow!("{}", args)))
Error::new_kind(ErrorKind::Value(anyhow::anyhow!("{}", args)))
}

/// Internal error of starlark.
Expand Down
2 changes: 1 addition & 1 deletion starlark_syntax/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum LexemeError {

impl From<LexemeError> for crate::error::Error {
fn from(e: LexemeError) -> Self {
crate::error::Error::new(crate::error::ErrorKind::Parser(anyhow::Error::new(e)))
crate::error::Error::new_kind(crate::error::ErrorKind::Parser(anyhow::Error::new(e)))
}
}

Expand Down

0 comments on commit 2010c4d

Please sign in to comment.