Sha256: fab74ada293c8452b589cf4c5a4e7b3e73537977b741b21af0825b01474b6eff

Contents?: true

Size: 1.23 KB

Versions: 44

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module RbSys
  # Error is the base class for all errors raised by rb_sys.
  class Error < StandardError; end

  # Raised when a package is not found from the Cargo metadata.
  class PackageNotFoundError < Error
    def initialize(name)
      msg = <<~MSG.chomp.tr("\n", " ")
        Could not find Cargo package metadata for #{@name.inspect}. Please
        check that #{@name.inspect} matches the crate name in your
        Cargo.toml."
      MSG

      super(msg)
    end
  end

  # Raised when Cargo metadata cannot be parsed.
  class CargoMetadataError < Error
    def initialize(err, stderr)
      msg = <<~MSG.chomp.tr("\n", " ")
        Could not infer Rust crate information using `cargo metadata`.

        Original error was:
          #{err.class}: #{err.message}

        Things to check:
          - Check that your ext/*/Cargo.toml at is valid
          - If you are using a workspace, make sure you are the root Cargo.toml exists
          - Make sure `cargo` is installed and in your PATH
      MSG

      if !stderr.empty?
        indented_stderr = stderr.lines.map { |line| "  #{line}" }.join
        msg << "Stderr from `cargo metadata` was:\n#{indented_stderr}"
      end

      super(msg)
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
rb_sys-0.9.109 lib/rb_sys/error.rb
rb_sys-0.9.108 lib/rb_sys/error.rb
rb_sys-0.9.107 lib/rb_sys/error.rb
rb_sys-0.9.106 lib/rb_sys/error.rb
rb_sys-0.9.105 lib/rb_sys/error.rb
rb_sys-0.9.104 lib/rb_sys/error.rb
rb_sys-0.9.103 lib/rb_sys/error.rb
rb_sys-0.9.102 lib/rb_sys/error.rb
rb_sys-0.9.101 lib/rb_sys/error.rb
rb_sys-0.9.100 lib/rb_sys/error.rb
rb_sys-0.9.99 lib/rb_sys/error.rb
rb_sys-0.9.98 lib/rb_sys/error.rb
rb_sys-0.9.97 lib/rb_sys/error.rb
rb_sys-0.9.96 lib/rb_sys/error.rb
rb_sys-0.9.94 lib/rb_sys/error.rb
rb_sys-0.9.93 lib/rb_sys/error.rb
rb_sys-0.9.92 lib/rb_sys/error.rb
rb_sys-0.9.91 lib/rb_sys/error.rb
rb_sys-0.9.90 lib/rb_sys/error.rb
rb_sys-0.9.89 lib/rb_sys/error.rb