cumulus3d-core 0.11.0

Core types for cumulus3d: camera models, rigid/similarity transforms, reconstruction graph, feature store, RANSAC, PLY/GPS I/O
Documentation
/*
 * error.rs
 *
 * Copyright (c) 2026 ParkSangWoo
 *
 * Author(s):
 *
 *      ParkSangWoo <dev.parksangwoo@gmail.com>
 *
 *
 * This file is part of cumulus3d.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

//! Error type.

use std::path::PathBuf;

/// Errors across core.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("입출력 오류: {0}")]
    /// I/O failure.
    Io(#[from] std::io::Error),
    #[error("구문 오류 ({path}:{line}): {msg}")]
    /// Text file syntax error (with location).
    Parse {
        /// File path.
        path: PathBuf,
        /// Line number (1-based).
        line: usize,
        /// Error description.
        msg: String,
    },
    #[error("형식 오류: {0}")]
    /// File format violation.
    Format(String),
    #[error("잘못된 인자: {0}")]
    /// Invalid argument.
    InvalidArgument(String),
    #[error("찾을 수 없음: {0}")]
    /// Target (id or name) not found.
    NotFound(String),
    #[error("이미 존재: {0}")]
    /// Attempt to add a target that already exists.
    AlreadyExists(String),
    #[error("불변식 위반: {0}")]
    /// Data structure invariant violation.
    Invariant(String),
    #[error("지원하지 않음: {0}")]
    /// Unsupported feature or model.
    Unsupported(String),
}

/// `Result` alias used across core.
pub type Result<T> = std::result::Result<T, Error>;

impl Error {
    pub(crate) fn parse(path: impl Into<PathBuf>, line: usize, msg: impl Into<String>) -> Self {
        Error::Parse { path: path.into(), line, msg: msg.into() }
    }
}