blob: a8008469cee0ef434b050d32daf8dfd16c0d7a6e [file]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
//! Closed diagnostic categories; private error payloads never cross this boundary.
use maka_config::ConfigError;
use maka_event_log::StoreError;
pub(crate) fn config_cause(error: &ConfigError) -> &'static str {
match error {
ConfigError::Invalid(_) => "config_invalid",
ConfigError::UnsupportedDatabase => "config_unsupported_database",
ConfigError::CommitUnknown => "config_commit_unknown",
ConfigError::Io(_) => "config_io",
ConfigError::Sqlite(_) => "config_sqlite",
ConfigError::Store(_) => "config_store",
ConfigError::Json(_) => "config_json",
}
}
pub(crate) fn store_cause(error: &StoreError) -> &'static str {
match error.underlying() {
StoreError::ConnectionClosed => "store_connection_closed",
StoreError::OperationUnknown => "store_operation_unknown",
StoreError::CommitUnknown(_) => "store_commit_unknown",
StoreError::Sqlite(_) => "store_sqlite",
StoreError::Io(_) => "store_io",
StoreError::Json(_) => "store_json",
StoreError::Migration(_) => "store_migration",
StoreError::Poisoned => "store_poisoned",
StoreError::CloseFailed(_) => "store_close_failed",
StoreError::StartupCleanupFailed { .. } => "store_startup_cleanup_failed",
StoreError::UnsupportedDatabase => "store_unsupported_database",
StoreError::Initialization => "store_initialization",
_ => "store_error",
}
}
pub(crate) fn store_sql_code(error: &StoreError) -> Option<i32> {
match error.underlying() {
StoreError::Sqlite(error) | StoreError::CommitUnknown(error) => {
error.sqlite_error().map(|error| error.extended_code)
}
_ => None,
}
}