// error names preserve the public API; messages follow pacman lib/libalpm/error.c. // SPDX-License-Identifier: GPL-2.0-or-later module engine pub enum Errno { ok = 0 memory system badperms not_a_file not_a_dir wrong_args disk_space handle_null handle_not_null handle_lock db_open db_create db_null db_not_null db_not_found db_invalid db_invalid_sig db_version db_write db_remove server_bad_url server_none trans_not_null trans_null trans_dup_target trans_dup_filename trans_not_initialized trans_not_prepared trans_abort trans_type trans_not_locked trans_hook_failed pkg_not_found pkg_ignored pkg_invalid pkg_invalid_checksum pkg_invalid_sig pkg_missing_sig pkg_open pkg_cant_remove pkg_invalid_name pkg_invalid_arch sig_missing sig_invalid unsatisfied_deps conflicting_deps file_conflicts retrieve_prepare retrieve invalid_regex libarchive libcurl external_download gpgme missing_capability_signatures } pub fn (kind Errno) strerror() string { message := match kind { .ok { 'unexpected error' } .memory { 'out of memory!' } .system { 'unexpected system error' } .badperms { 'permission denied' } .not_a_file { 'could not find or read file' } .not_a_dir { 'could not find or read directory' } .wrong_args { 'wrong or NULL argument passed' } .disk_space { 'not enough free disk space' } .handle_null { 'library not initialized' } .handle_not_null { 'library already initialized' } .handle_lock { 'unable to lock database' } .db_open { 'could not open database' } .db_create { 'could not create database' } .db_null { 'database not initialized' } .db_not_null { 'database already registered' } .db_not_found { 'could not find database' } .db_invalid { 'invalid or corrupted database' } .db_invalid_sig { 'invalid or corrupted database (PGP signature)' } .db_version { 'database is incorrect version' } .db_write { 'could not update database' } .db_remove { 'could not remove database entry' } .server_bad_url { 'invalid url for server' } .server_none { 'no servers configured for repository' } .trans_not_null { 'transaction already initialized' } .trans_null { 'transaction not initialized' } .trans_dup_target { 'duplicate target' } .trans_dup_filename { 'duplicate filename' } .trans_not_initialized { 'transaction not initialized' } .trans_not_prepared { 'transaction not prepared' } .trans_abort { 'transaction aborted' } .trans_type { 'operation not compatible with the transaction type' } .trans_not_locked { 'transaction commit attempt when database is not locked' } .trans_hook_failed { 'failed to run transaction hooks' } .pkg_not_found { 'could not find or read package' } .pkg_ignored { 'operation cancelled due to ignorepkg' } .pkg_invalid { 'invalid or corrupted package' } .pkg_invalid_checksum { 'invalid or corrupted package (checksum)' } .pkg_invalid_sig { 'invalid or corrupted package (PGP signature)' } .pkg_missing_sig { 'package missing required signature' } .pkg_open { 'cannot open package file' } .pkg_cant_remove { 'cannot remove all files for package' } .pkg_invalid_name { 'package filename is not valid' } .pkg_invalid_arch { 'package architecture is not valid' } .sig_missing { 'missing PGP signature' } .sig_invalid { 'invalid PGP signature' } .unsatisfied_deps { 'could not satisfy dependencies' } .conflicting_deps { 'conflicting dependencies' } .file_conflicts { 'conflicting files' } .retrieve_prepare { 'failed to initialize download' } .retrieve { 'failed to retrieve some files' } .invalid_regex { 'invalid regular expression' } .libarchive { 'libarchive error' } .libcurl { 'download library error' } .external_download { 'error invoking external downloader' } .gpgme { 'gpgme error' } .missing_capability_signatures { 'compiled without signature support' } else { 'unexpected error' } } return translated_message(message) } pub struct AlpmError { pub: kind Errno detail string } pub fn (problem AlpmError) msg() string { return if problem.detail == '' { problem.kind.strerror() } else { problem.kind.strerror() + ': ' + problem.detail } } pub fn (problem AlpmError) code() int { return int(problem.kind) }