ukiryu 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +58 -14
- data/.gitignore +3 -0
- data/.rubocop_todo.yml +170 -79
- data/Gemfile +1 -1
- data/README.adoc +1603 -576
- data/docs/.gitignore +1 -0
- data/docs/Gemfile +10 -0
- data/docs/INDEX.adoc +261 -0
- data/docs/_config.yml +180 -0
- data/docs/advanced/custom-tool-classes.adoc +581 -0
- data/docs/advanced/index.adoc +20 -0
- data/docs/features/configuration.adoc +657 -0
- data/docs/features/index.adoc +31 -0
- data/docs/features/platform-support.adoc +488 -0
- data/docs/getting-started/core-concepts.adoc +666 -0
- data/docs/getting-started/index.adoc +36 -0
- data/docs/getting-started/installation.adoc +216 -0
- data/docs/getting-started/quick-start.adoc +258 -0
- data/docs/guides/env-var-sets.adoc +388 -0
- data/docs/guides/index.adoc +20 -0
- data/docs/interfaces/cli.adoc +609 -0
- data/docs/interfaces/index.adoc +153 -0
- data/docs/interfaces/ruby-api.adoc +538 -0
- data/docs/lychee.toml +49 -0
- data/docs/reference/configuration-options.adoc +720 -0
- data/docs/reference/error-codes.adoc +634 -0
- data/docs/reference/index.adoc +20 -0
- data/docs/reference/ruby-api.adoc +1217 -0
- data/docs/understanding/index.adoc +20 -0
- data/lib/ukiryu/cli.rb +43 -58
- data/lib/ukiryu/cli_commands/base_command.rb +16 -27
- data/lib/ukiryu/cli_commands/cache_command.rb +100 -0
- data/lib/ukiryu/cli_commands/commands_command.rb +8 -8
- data/lib/ukiryu/cli_commands/commands_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/config_command.rb +49 -7
- data/lib/ukiryu/cli_commands/definitions_command.rb +254 -0
- data/lib/ukiryu/cli_commands/describe_command.rb +13 -7
- data/lib/ukiryu/cli_commands/describe_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/docs_command.rb +148 -0
- data/lib/ukiryu/cli_commands/exec_inline_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/extract_command.rb +2 -2
- data/lib/ukiryu/cli_commands/info_command.rb +7 -7
- data/lib/ukiryu/cli_commands/lint_command.rb +167 -0
- data/lib/ukiryu/cli_commands/list_command.rb +6 -6
- data/lib/ukiryu/cli_commands/opts_command.rb +2 -2
- data/lib/ukiryu/cli_commands/opts_command.rb.fixed +1 -1
- data/lib/ukiryu/cli_commands/register_command.rb +144 -0
- data/lib/ukiryu/cli_commands/resolve_command.rb +124 -0
- data/lib/ukiryu/cli_commands/run_command.rb +38 -14
- data/lib/ukiryu/cli_commands/run_file_command.rb +2 -2
- data/lib/ukiryu/cli_commands/system_command.rb +50 -32
- data/lib/ukiryu/cli_commands/validate_command.rb +452 -51
- data/lib/ukiryu/cli_commands/which_command.rb +5 -5
- data/lib/ukiryu/command_builder.rb +81 -23
- data/lib/ukiryu/config/env_provider.rb +3 -3
- data/lib/ukiryu/config/env_schema.rb +6 -6
- data/lib/ukiryu/config.rb +11 -11
- data/lib/ukiryu/definition/definition_cache.rb +238 -0
- data/lib/ukiryu/definition/definition_composer.rb +257 -0
- data/lib/ukiryu/definition/definition_linter.rb +460 -0
- data/lib/ukiryu/definition/definition_validator.rb +320 -0
- data/lib/ukiryu/definition/discovery.rb +239 -0
- data/lib/ukiryu/definition/documentation_generator.rb +429 -0
- data/lib/ukiryu/definition/lint_issue.rb +168 -0
- data/lib/ukiryu/definition/loader.rb +139 -0
- data/lib/ukiryu/definition/metadata.rb +159 -0
- data/lib/ukiryu/definition/source.rb +87 -0
- data/lib/ukiryu/definition/sources/file.rb +138 -0
- data/lib/ukiryu/definition/sources/string.rb +88 -0
- data/lib/ukiryu/definition/validation_result.rb +158 -0
- data/lib/ukiryu/definition/version_resolver.rb +194 -0
- data/lib/ukiryu/definition.rb +40 -0
- data/lib/ukiryu/errors.rb +6 -0
- data/lib/ukiryu/execution_context.rb +11 -11
- data/lib/ukiryu/executor.rb +6 -0
- data/lib/ukiryu/extractors/extractor.rb +6 -5
- data/lib/ukiryu/extractors/help_parser.rb +13 -19
- data/lib/ukiryu/logger.rb +3 -1
- data/lib/ukiryu/models/command_definition.rb +3 -3
- data/lib/ukiryu/models/command_info.rb +1 -1
- data/lib/ukiryu/models/components.rb +1 -3
- data/lib/ukiryu/models/env_var_definition.rb +11 -3
- data/lib/ukiryu/models/flag_definition.rb +15 -0
- data/lib/ukiryu/models/option_definition.rb +7 -7
- data/lib/ukiryu/models/platform_profile.rb +6 -3
- data/lib/ukiryu/models/routing.rb +1 -1
- data/lib/ukiryu/models/tool_definition.rb +2 -4
- data/lib/ukiryu/models/tool_metadata.rb +6 -6
- data/lib/ukiryu/models/validation_result.rb +1 -1
- data/lib/ukiryu/models/version_compatibility.rb +6 -3
- data/lib/ukiryu/models/version_detection.rb +10 -1
- data/lib/ukiryu/{registry.rb → register.rb} +54 -38
- data/lib/ukiryu/register_auto_manager.rb +268 -0
- data/lib/ukiryu/schema_validator.rb +31 -10
- data/lib/ukiryu/shell/base.rb +18 -0
- data/lib/ukiryu/shell/bash.rb +19 -1
- data/lib/ukiryu/shell/cmd.rb +11 -1
- data/lib/ukiryu/shell/powershell.rb +11 -1
- data/lib/ukiryu/shell.rb +1 -1
- data/lib/ukiryu/tool.rb +107 -95
- data/lib/ukiryu/tool_index.rb +22 -22
- data/lib/ukiryu/tools/base.rb +12 -25
- data/lib/ukiryu/tools/generator.rb +7 -7
- data/lib/ukiryu/tools.rb +3 -3
- data/lib/ukiryu/type.rb +20 -5
- data/lib/ukiryu/version.rb +1 -1
- data/lib/ukiryu/version_detector.rb +21 -2
- data/lib/ukiryu.rb +6 -3
- data/ukiryu-proposal.md +41 -41
- data/ukiryu.gemspec +1 -0
- metadata +64 -8
- data/.gitmodules +0 -3
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Error Codes
|
|
4
|
+
parent: Reference
|
|
5
|
+
nav_order: 3
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
== Error Codes
|
|
9
|
+
|
|
10
|
+
This page documents all error types raised by Ukiryu, their meanings, and recovery strategies.
|
|
11
|
+
|
|
12
|
+
// Overview
|
|
13
|
+
== Overview
|
|
14
|
+
|
|
15
|
+
Ukiryu uses Ruby's exception mechanism to report errors. All errors inherit from `Ukiryu::Error`, allowing you to catch all Ukiryu-specific errors with a single rescue clause.
|
|
16
|
+
|
|
17
|
+
// Error Hierarchy
|
|
18
|
+
== Error Hierarchy
|
|
19
|
+
|
|
20
|
+
.Error inheritance tree
|
|
21
|
+
[source,ruby]
|
|
22
|
+
----
|
|
23
|
+
Ukiryu::Error # Base error class
|
|
24
|
+
|
|
|
25
|
+
+- Ukiryu::UnknownShellError # Shell detection failed
|
|
26
|
+
+- Ukiryu::UnsupportedPlatformError # Platform not supported
|
|
27
|
+
+- Ukiryu::ValidationError # Type validation failed
|
|
28
|
+
+- Ukiryu::LoadError # Legacy load error (use DefinitionError)
|
|
29
|
+
+- Ukiryu::VersionDetectionError # Version detection failed
|
|
30
|
+
|
|
|
31
|
+
+- Ukiryu::ProfileNotFoundError # No compatible profile found
|
|
32
|
+
+- Ukiryu::ProfileLoadError # Profile loading failed
|
|
33
|
+
|
|
|
34
|
+
+- Ukiryu::DefinitionError # Definition-related errors
|
|
35
|
+
| |
|
|
36
|
+
| +- Ukiryu::DefinitionNotFoundError # Definition file not found
|
|
37
|
+
| +- Ukiryu::DefinitionLoadError # Definition parsing failed
|
|
38
|
+
| +- Ukiryu::DefinitionValidationError # Definition validation failed
|
|
39
|
+
|
|
|
40
|
+
+- Ukiryu::ToolNotFoundError # Tool not in register
|
|
41
|
+
+- Ukiryu::ExecutableNotFoundError # Tool executable not found
|
|
42
|
+
|
|
|
43
|
+
+- Ukiryu::ExecutionError # Command execution failed
|
|
44
|
+
+- Ukiryu::TimeoutError # Command timeout exceeded
|
|
45
|
+
----
|
|
46
|
+
|
|
47
|
+
// Error Types
|
|
48
|
+
== Error Types
|
|
49
|
+
|
|
50
|
+
=== Base Error
|
|
51
|
+
|
|
52
|
+
==== Ukiryu::Error
|
|
53
|
+
|
|
54
|
+
*Base class for all Ukiryu errors.*
|
|
55
|
+
|
|
56
|
+
* **Meaning**: Generic Ukiryu error
|
|
57
|
+
* **When raised**: As a fallback for unspecified errors
|
|
58
|
+
* **Recovery**: Check error message for details
|
|
59
|
+
|
|
60
|
+
[source,ruby]
|
|
61
|
+
----
|
|
62
|
+
begin
|
|
63
|
+
# ... Ukiryu operations ...
|
|
64
|
+
rescue Ukiryu::Error => e
|
|
65
|
+
puts "Ukiryu error: #{e.message}"
|
|
66
|
+
end
|
|
67
|
+
----
|
|
68
|
+
|
|
69
|
+
=== Shell and Platform Errors
|
|
70
|
+
|
|
71
|
+
==== Ukiryu::UnknownShellError
|
|
72
|
+
|
|
73
|
+
*Shell detection or specification failed.*
|
|
74
|
+
|
|
75
|
+
* **Meaning**: Cannot determine or use the specified shell
|
|
76
|
+
* **When raised**:
|
|
77
|
+
* Shell cannot be auto-detected
|
|
78
|
+
* Specified shell is not supported
|
|
79
|
+
* Shell executable not found
|
|
80
|
+
* **Recovery**:
|
|
81
|
+
* Specify a supported shell: `bash`, `zsh`, `fish`, `sh`, `powershell`, `cmd`
|
|
82
|
+
* Install the shell if missing
|
|
83
|
+
* Check `UKIRYU_SHELL` environment variable
|
|
84
|
+
|
|
85
|
+
[source,ruby]
|
|
86
|
+
----
|
|
87
|
+
begin
|
|
88
|
+
tool = Ukiryu::Tool.get(:imagemagick, shell: :unknown_shell)
|
|
89
|
+
rescue Ukiryu::UnknownShellError => e
|
|
90
|
+
puts "Shell error: #{e.message}"
|
|
91
|
+
# Try with auto-detected shell
|
|
92
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
93
|
+
end
|
|
94
|
+
----
|
|
95
|
+
|
|
96
|
+
==== Ukiryu::UnsupportedPlatformError
|
|
97
|
+
|
|
98
|
+
*Platform is not supported.*
|
|
99
|
+
|
|
100
|
+
* **Meaning**: Current platform is not supported
|
|
101
|
+
* **When raised**: Running on an unsupported operating system
|
|
102
|
+
* **Recovery**: Ukiryu supports `:macos`, `:linux`, and `:windows`
|
|
103
|
+
|
|
104
|
+
[source,ruby]
|
|
105
|
+
----
|
|
106
|
+
begin
|
|
107
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
108
|
+
rescue Ukiryu::UnsupportedPlatformError => e
|
|
109
|
+
puts "Platform not supported: #{e.message}"
|
|
110
|
+
end
|
|
111
|
+
----
|
|
112
|
+
|
|
113
|
+
=== Validation Errors
|
|
114
|
+
|
|
115
|
+
==== Ukiryu::ValidationError
|
|
116
|
+
|
|
117
|
+
*Type validation failed.*
|
|
118
|
+
|
|
119
|
+
* **Meaning**: Parameter value does not match expected type or constraints
|
|
120
|
+
* **When raised**:
|
|
121
|
+
* Wrong type for parameter
|
|
122
|
+
* Value outside allowed range
|
|
123
|
+
* Value not in allowed enumeration
|
|
124
|
+
* **Recovery**:
|
|
125
|
+
* Check parameter type against tool definition
|
|
126
|
+
* Verify value is within range
|
|
127
|
+
* Ensure value is in allowed values list
|
|
128
|
+
|
|
129
|
+
[source,ruby]
|
|
130
|
+
----
|
|
131
|
+
begin
|
|
132
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
133
|
+
result = tool.execute(:export, {
|
|
134
|
+
format: :unsupported, # Not in values list
|
|
135
|
+
dpi: -5 # Outside range 1-10000
|
|
136
|
+
})
|
|
137
|
+
rescue Ukiryu::ValidationError => e
|
|
138
|
+
puts "Validation error: #{e.message}"
|
|
139
|
+
# Correct the parameters and retry
|
|
140
|
+
result = tool.execute(:export, {
|
|
141
|
+
format: :png,
|
|
142
|
+
dpi: 300
|
|
143
|
+
})
|
|
144
|
+
end
|
|
145
|
+
----
|
|
146
|
+
|
|
147
|
+
=== Profile Errors
|
|
148
|
+
|
|
149
|
+
==== Ukiryu::ProfileNotFoundError
|
|
150
|
+
|
|
151
|
+
*No compatible profile found for the current platform/shell.*
|
|
152
|
+
|
|
153
|
+
* **Meaning**: Tool definition exists but has no profile for current platform/shell combination
|
|
154
|
+
* **When raised**:
|
|
155
|
+
* No profile matches current platform
|
|
156
|
+
* No profile matches current shell
|
|
157
|
+
* Version constraint not satisfied
|
|
158
|
+
* **Recovery**:
|
|
159
|
+
* Check tool definition has profile for your platform
|
|
160
|
+
* Check tool definition has profile for your shell
|
|
161
|
+
* Try specifying platform/shell explicitly
|
|
162
|
+
* Verify tool version matches profile requirements
|
|
163
|
+
|
|
164
|
+
[source,ruby]
|
|
165
|
+
----
|
|
166
|
+
begin
|
|
167
|
+
tool = Ukiryu::Tool.get(:imagemagick, platform: :windows)
|
|
168
|
+
rescue Ukiryu::ProfileNotFoundError => e
|
|
169
|
+
puts "No profile for this platform: #{e.message}"
|
|
170
|
+
# Try without platform constraint
|
|
171
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
172
|
+
end
|
|
173
|
+
----
|
|
174
|
+
|
|
175
|
+
==== Ukiryu::ProfileLoadError
|
|
176
|
+
|
|
177
|
+
*Profile loading failed.*
|
|
178
|
+
|
|
179
|
+
* **Meaning**: Cannot load tool profile from definition
|
|
180
|
+
* **When raised**: Corrupted or invalid profile data
|
|
181
|
+
* **Recovery**:
|
|
182
|
+
* Verify YAML syntax is correct
|
|
183
|
+
* Check profile structure matches schema
|
|
184
|
+
* Review error message for specific issue
|
|
185
|
+
|
|
186
|
+
[source,ruby]
|
|
187
|
+
----
|
|
188
|
+
begin
|
|
189
|
+
tool = Ukiryu::Tool.get(:broken_tool)
|
|
190
|
+
rescue Ukiryu::ProfileLoadError => e
|
|
191
|
+
puts "Profile load error: #{e.message}"
|
|
192
|
+
# Check tool definition file
|
|
193
|
+
end
|
|
194
|
+
----
|
|
195
|
+
|
|
196
|
+
=== Definition Errors
|
|
197
|
+
|
|
198
|
+
==== Ukiryu::DefinitionError
|
|
199
|
+
|
|
200
|
+
*Base class for definition-related errors.*
|
|
201
|
+
|
|
202
|
+
* **Meaning**: Generic definition error
|
|
203
|
+
* **When raised**: As a fallback for definition-related issues
|
|
204
|
+
* **Recovery**: Check error message and definition file
|
|
205
|
+
|
|
206
|
+
==== Ukiryu::DefinitionNotFoundError
|
|
207
|
+
|
|
208
|
+
*Definition file not found.*
|
|
209
|
+
|
|
210
|
+
* **Meaning**: Specified definition file does not exist
|
|
211
|
+
* **When raised**:
|
|
212
|
+
* File path does not exist
|
|
213
|
+
* Using `Tool.from_file` with invalid path
|
|
214
|
+
* Using `Tool.from_bundled` with no bundled definition
|
|
215
|
+
* **Recovery**:
|
|
216
|
+
* Verify file path is correct
|
|
217
|
+
* Check file has `.yaml` extension
|
|
218
|
+
* Use absolute path if relative path fails
|
|
219
|
+
* Check tool is in register
|
|
220
|
+
|
|
221
|
+
[source,ruby]
|
|
222
|
+
----
|
|
223
|
+
begin
|
|
224
|
+
tool = Ukiryu::Tool.load('/nonexistent/tool.yaml')
|
|
225
|
+
rescue Ukiryu::DefinitionNotFoundError => e
|
|
226
|
+
puts "Definition not found: #{e.message}"
|
|
227
|
+
# Check file path
|
|
228
|
+
if File.exist?('/path/to/tool.yaml')
|
|
229
|
+
tool = Ukiryu::Tool.load('/path/to/tool.yaml')
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
----
|
|
233
|
+
|
|
234
|
+
==== Ukiryu::DefinitionLoadError
|
|
235
|
+
|
|
236
|
+
*Definition parsing or loading failed.*
|
|
237
|
+
|
|
238
|
+
* **Meaning**: Cannot parse or load definition file
|
|
239
|
+
* **When raised**:
|
|
240
|
+
* Invalid YAML syntax
|
|
241
|
+
* File cannot be read
|
|
242
|
+
* Encoding issues
|
|
243
|
+
* **Recovery**:
|
|
244
|
+
* Validate YAML syntax
|
|
245
|
+
* Check file is readable
|
|
246
|
+
* Verify file encoding is UTF-8
|
|
247
|
+
* Use `ukiryu validate` to check definition
|
|
248
|
+
|
|
249
|
+
[source,ruby]
|
|
250
|
+
----
|
|
251
|
+
begin
|
|
252
|
+
tool = Ukiryu::Tool.load('/path/to/tool.yaml')
|
|
253
|
+
rescue Ukiryu::DefinitionLoadError => e
|
|
254
|
+
puts "Definition load error: #{e.message}"
|
|
255
|
+
# Validate the definition
|
|
256
|
+
system('ukiryu', 'validate', '--definition', '/path/to/tool.yaml')
|
|
257
|
+
end
|
|
258
|
+
----
|
|
259
|
+
|
|
260
|
+
==== Ukiryu::DefinitionValidationError
|
|
261
|
+
|
|
262
|
+
*Definition validation failed.*
|
|
263
|
+
|
|
264
|
+
* **Meaning**: Definition does not conform to schema or validation rules
|
|
265
|
+
* **When raised**:
|
|
266
|
+
* Missing required fields
|
|
267
|
+
* Invalid field values
|
|
268
|
+
* Schema violations
|
|
269
|
+
* **Recovery**:
|
|
270
|
+
* Run `ukiryu validate` for detailed errors
|
|
271
|
+
* Compare with schema
|
|
272
|
+
* Check tool definition examples
|
|
273
|
+
* Fix validation errors and retry
|
|
274
|
+
|
|
275
|
+
[source,ruby]
|
|
276
|
+
----
|
|
277
|
+
begin
|
|
278
|
+
tool = Ukiryu::Tool.load('/path/to/invalid.yaml')
|
|
279
|
+
rescue Ukiryu::DefinitionValidationError => e
|
|
280
|
+
puts "Definition validation error: #{e.message}"
|
|
281
|
+
# Validate for detailed errors
|
|
282
|
+
system('ukiryu', 'validate', '--definition', '/path/to/invalid.yaml')
|
|
283
|
+
end
|
|
284
|
+
----
|
|
285
|
+
|
|
286
|
+
=== Tool Errors
|
|
287
|
+
|
|
288
|
+
==== Ukiryu::ToolNotFoundError
|
|
289
|
+
|
|
290
|
+
*Tool not found in register.*
|
|
291
|
+
|
|
292
|
+
* **Meaning**: Tool name does not exist in tool register
|
|
293
|
+
* **When raised**:
|
|
294
|
+
* Tool name not in register
|
|
295
|
+
* Register path is incorrect
|
|
296
|
+
* Tool not installed
|
|
297
|
+
* **Recovery**:
|
|
298
|
+
* Check tool name spelling
|
|
299
|
+
* Verify register path is correct
|
|
300
|
+
* List available tools with `ukiryu list`
|
|
301
|
+
* Check `UKIRYU_REGISTER` environment variable
|
|
302
|
+
|
|
303
|
+
[source,ruby]
|
|
304
|
+
----
|
|
305
|
+
begin
|
|
306
|
+
tool = Ukiryu::Tool.get(:nonexistent_tool)
|
|
307
|
+
rescue Ukiryu::ToolNotFoundError => e
|
|
308
|
+
puts "Tool not found: #{e.message}"
|
|
309
|
+
puts "Available tools: #{Ukiryu::Register.tools.join(', ')}"
|
|
310
|
+
end
|
|
311
|
+
----
|
|
312
|
+
|
|
313
|
+
==== Ukiryu::ExecutableNotFoundError
|
|
314
|
+
|
|
315
|
+
*Tool executable not found on system.*
|
|
316
|
+
|
|
317
|
+
* **Meaning**: Tool is defined in register but executable not found
|
|
318
|
+
* **When raised**:
|
|
319
|
+
* Tool not installed
|
|
320
|
+
* Executable not in PATH
|
|
321
|
+
* Search paths don't contain executable
|
|
322
|
+
* **Recovery**:
|
|
323
|
+
* Install the tool
|
|
324
|
+
* Add executable to PATH
|
|
325
|
+
* Configure search_paths in tool definition
|
|
326
|
+
* Use `ukiryu which TOOL` to check executable location
|
|
327
|
+
|
|
328
|
+
[source,ruby]
|
|
329
|
+
----
|
|
330
|
+
begin
|
|
331
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
332
|
+
result = tool.execute(:convert, params)
|
|
333
|
+
rescue Ukiryu::ExecutableNotFoundError => e
|
|
334
|
+
puts "Executable not found: #{e.message}"
|
|
335
|
+
puts "Install ImageMagick or configure search paths"
|
|
336
|
+
end
|
|
337
|
+
----
|
|
338
|
+
|
|
339
|
+
=== Execution Errors
|
|
340
|
+
|
|
341
|
+
==== Ukiryu::ExecutionError
|
|
342
|
+
|
|
343
|
+
*Command execution failed.*
|
|
344
|
+
|
|
345
|
+
* **Meaning**: Tool command returned non-zero exit code
|
|
346
|
+
* **When raised**:
|
|
347
|
+
* Command failed (exit code != 0)
|
|
348
|
+
* `allow_failure: false` (default)
|
|
349
|
+
* **Recovery**:
|
|
350
|
+
* Check `e.result.exit_status` for exit code
|
|
351
|
+
* Check `e.result.stderr` for error message
|
|
352
|
+
* Verify parameters are correct
|
|
353
|
+
* Use `allow_failure: true` to handle failures gracefully
|
|
354
|
+
|
|
355
|
+
[source,ruby]
|
|
356
|
+
----
|
|
357
|
+
begin
|
|
358
|
+
tool = Ukiryu::Tool.get(:inkscape)
|
|
359
|
+
result = tool.execute(:export, params)
|
|
360
|
+
rescue Ukiryu::ExecutionError => e
|
|
361
|
+
puts "Command failed!"
|
|
362
|
+
puts "Exit code: #{e.result.exit_status}"
|
|
363
|
+
puts "Stderr: #{e.result.stderr}"
|
|
364
|
+
puts "Command: #{e.result.command_info.full_command}"
|
|
365
|
+
end
|
|
366
|
+
----
|
|
367
|
+
|
|
368
|
+
==== Ukiryu::TimeoutError
|
|
369
|
+
|
|
370
|
+
*Command execution exceeded timeout.*
|
|
371
|
+
|
|
372
|
+
* **Meaning**: Tool command took longer than allowed timeout
|
|
373
|
+
* **When raised**:
|
|
374
|
+
* Command exceeded default timeout (90s)
|
|
375
|
+
* Command exceeded custom timeout
|
|
376
|
+
* **Recovery**:
|
|
377
|
+
* Increase timeout parameter
|
|
378
|
+
* Check `UKIRYU_TIMEOUT` environment variable
|
|
379
|
+
* Verify tool is not hanging
|
|
380
|
+
* Optimize command parameters
|
|
381
|
+
|
|
382
|
+
[source,ruby]
|
|
383
|
+
----
|
|
384
|
+
begin
|
|
385
|
+
tool = Ukiryu::Tool.get(:ghostscript)
|
|
386
|
+
result = tool.execute(:convert, large_pdf_params, timeout: 30)
|
|
387
|
+
rescue Ukiryu::TimeoutError => e
|
|
388
|
+
puts "Command timed out after #{e.timeout} seconds"
|
|
389
|
+
# Retry with longer timeout
|
|
390
|
+
result = tool.execute(:convert, large_pdf_params, timeout: 300)
|
|
391
|
+
end
|
|
392
|
+
----
|
|
393
|
+
|
|
394
|
+
=== Version Errors
|
|
395
|
+
|
|
396
|
+
==== Ukiryu::VersionDetectionError
|
|
397
|
+
|
|
398
|
+
*Version detection failed.*
|
|
399
|
+
|
|
400
|
+
* **Meaning**: Cannot determine installed tool version
|
|
401
|
+
* **When raised**:
|
|
402
|
+
* Version command failed
|
|
403
|
+
* Version pattern not matched
|
|
404
|
+
* Tool not responding to version command
|
|
405
|
+
* **Recovery**:
|
|
406
|
+
* Verify tool is installed correctly
|
|
407
|
+
* Check version_detection command in tool definition
|
|
408
|
+
* Test version command manually
|
|
409
|
+
* Update version pattern if needed
|
|
410
|
+
|
|
411
|
+
[source,ruby]
|
|
412
|
+
----
|
|
413
|
+
begin
|
|
414
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
415
|
+
version = tool.version
|
|
416
|
+
rescue Ukiryu::VersionDetectionError => e
|
|
417
|
+
puts "Version detection failed: #{e.message}"
|
|
418
|
+
# Tool will still work, but version is unknown
|
|
419
|
+
puts "Continuing without version info..."
|
|
420
|
+
end
|
|
421
|
+
----
|
|
422
|
+
|
|
423
|
+
=== Legacy Error
|
|
424
|
+
|
|
425
|
+
==== Ukiryu::LoadError
|
|
426
|
+
|
|
427
|
+
*Legacy load error (deprecated).*
|
|
428
|
+
|
|
429
|
+
* **Meaning**: Generic loading error
|
|
430
|
+
* **Deprecation Note**: Use `DefinitionError` instead
|
|
431
|
+
* **When raised**: As fallback for load-related issues
|
|
432
|
+
* **Recovery**: Update code to catch `DefinitionError`
|
|
433
|
+
|
|
434
|
+
[source,ruby]
|
|
435
|
+
----
|
|
436
|
+
# Legacy code (still works but deprecated)
|
|
437
|
+
begin
|
|
438
|
+
tool = Ukiryu::Tool.load('/path/to/tool.yaml')
|
|
439
|
+
rescue Ukiryu::LoadError => e
|
|
440
|
+
puts "Load error: #{e.message}"
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
# Updated code
|
|
444
|
+
begin
|
|
445
|
+
tool = Ukiryu::Tool.load('/path/to/tool.yaml')
|
|
446
|
+
rescue Ukiryu::DefinitionError => e
|
|
447
|
+
puts "Definition error: #{e.message}"
|
|
448
|
+
end
|
|
449
|
+
----
|
|
450
|
+
|
|
451
|
+
// Error Handling Patterns
|
|
452
|
+
== Error Handling Patterns
|
|
453
|
+
|
|
454
|
+
=== Catch All Ukiryu Errors
|
|
455
|
+
|
|
456
|
+
[source,ruby]
|
|
457
|
+
----
|
|
458
|
+
begin
|
|
459
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
460
|
+
result = tool.execute(:convert, params)
|
|
461
|
+
rescue Ukiryu::Error => e
|
|
462
|
+
# Catch all Ukiryu-specific errors
|
|
463
|
+
logger.error("Ukiryu error: #{e.message}")
|
|
464
|
+
raise
|
|
465
|
+
rescue => e
|
|
466
|
+
# Catch other errors (StandardError subclasses)
|
|
467
|
+
logger.error("Unexpected error: #{e.message}")
|
|
468
|
+
raise
|
|
469
|
+
end
|
|
470
|
+
----
|
|
471
|
+
|
|
472
|
+
=== Specific Error Recovery
|
|
473
|
+
|
|
474
|
+
[source,ruby]
|
|
475
|
+
----
|
|
476
|
+
require 'ukiryu'
|
|
477
|
+
|
|
478
|
+
class ToolExecutor
|
|
479
|
+
def execute_with_retry(tool_name, command, params, max_retries = 3)
|
|
480
|
+
tool = Ukiryu::Tool.get(tool_name)
|
|
481
|
+
retries = 0
|
|
482
|
+
|
|
483
|
+
begin
|
|
484
|
+
tool.execute(command, params)
|
|
485
|
+
|
|
486
|
+
rescue Ukiryu::ExecutableNotFoundError => e
|
|
487
|
+
# Fatal error - don't retry
|
|
488
|
+
raise
|
|
489
|
+
|
|
490
|
+
rescue Ukiryu::TimeoutError => e
|
|
491
|
+
# Retry with longer timeout
|
|
492
|
+
retries += 1
|
|
493
|
+
if retries < max_retries
|
|
494
|
+
new_timeout = e.timeout * 2
|
|
495
|
+
puts "Timeout, retrying with #{new_timeout}s timeout..."
|
|
496
|
+
tool.execute(command, params, timeout: new_timeout)
|
|
497
|
+
else
|
|
498
|
+
raise
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
rescue Ukiryu::ExecutionError => e
|
|
502
|
+
# Command failed - check if retryable
|
|
503
|
+
if retryable_exit_code?(e.result.exit_status) && retries < max_retries
|
|
504
|
+
retries += 1
|
|
505
|
+
sleep(2 ** retries) # Exponential backoff
|
|
506
|
+
retry
|
|
507
|
+
else
|
|
508
|
+
raise
|
|
509
|
+
end
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
private
|
|
514
|
+
|
|
515
|
+
def retryable_exit_code?(code)
|
|
516
|
+
# Define which exit codes are retryable
|
|
517
|
+
[1, 130].include?(code)
|
|
518
|
+
end
|
|
519
|
+
end
|
|
520
|
+
----
|
|
521
|
+
|
|
522
|
+
=== Allow Failure Pattern
|
|
523
|
+
|
|
524
|
+
[source,ruby]
|
|
525
|
+
----
|
|
526
|
+
# Execute without raising on non-zero exit
|
|
527
|
+
result = tool.execute(:convert, params, allow_failure: true)
|
|
528
|
+
|
|
529
|
+
if result.failure?
|
|
530
|
+
# Handle failure gracefully
|
|
531
|
+
if result.exit_status == 127
|
|
532
|
+
puts "Command not found"
|
|
533
|
+
elsif result.stderr.include?('timeout')
|
|
534
|
+
puts "Operation timed out"
|
|
535
|
+
else
|
|
536
|
+
puts "Command failed: #{result.stderr}"
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
----
|
|
540
|
+
|
|
541
|
+
// Error Information
|
|
542
|
+
== Error Information
|
|
543
|
+
|
|
544
|
+
=== ExecutionError Result Access
|
|
545
|
+
|
|
546
|
+
When `ExecutionError` is raised, the result object is accessible:
|
|
547
|
+
|
|
548
|
+
[source,ruby]
|
|
549
|
+
----
|
|
550
|
+
begin
|
|
551
|
+
result = tool.execute(:convert, params)
|
|
552
|
+
rescue Ukiryu::ExecutionError => e
|
|
553
|
+
result = e.result
|
|
554
|
+
|
|
555
|
+
# Access all result information
|
|
556
|
+
puts "Exit status: #{result.exit_status}"
|
|
557
|
+
puts "Executable: #{result.command_info.executable}"
|
|
558
|
+
puts "Command: #{result.command_info.full_command}"
|
|
559
|
+
puts "Shell: #{result.command_info.shell}"
|
|
560
|
+
puts "Stdout: #{result.stdout}"
|
|
561
|
+
puts "Stderr: #{result.stderr}"
|
|
562
|
+
puts "Duration: #{result.metadata.duration_seconds}s"
|
|
563
|
+
end
|
|
564
|
+
----
|
|
565
|
+
|
|
566
|
+
=== Timeout Information
|
|
567
|
+
|
|
568
|
+
[source,ruby]
|
|
569
|
+
----
|
|
570
|
+
begin
|
|
571
|
+
result = tool.execute(:convert, params, timeout: 30)
|
|
572
|
+
rescue Ukiryu::TimeoutError => e
|
|
573
|
+
puts "Command timed out after #{e.timeout} seconds"
|
|
574
|
+
puts "Command was: #{e.result.command_info.full_command}"
|
|
575
|
+
end
|
|
576
|
+
----
|
|
577
|
+
|
|
578
|
+
// Debugging Errors
|
|
579
|
+
== Debugging Errors
|
|
580
|
+
|
|
581
|
+
=== Enable Debug Mode
|
|
582
|
+
|
|
583
|
+
Set `UKIRYU_DEBUG=1` for structured debug output:
|
|
584
|
+
|
|
585
|
+
[source,shell]
|
|
586
|
+
----
|
|
587
|
+
export UKIRYU_DEBUG=1
|
|
588
|
+
ukiryu exec imagemagick convert input.jpg output.png
|
|
589
|
+
----
|
|
590
|
+
|
|
591
|
+
[source,ruby]
|
|
592
|
+
----
|
|
593
|
+
ENV['UKIRYU_DEBUG'] = 'true'
|
|
594
|
+
tool = Ukiryu::Tool.get(:imagemagick)
|
|
595
|
+
result = tool.execute(:convert, params)
|
|
596
|
+
----
|
|
597
|
+
|
|
598
|
+
=== Validate Definitions
|
|
599
|
+
|
|
600
|
+
Use the validate command to check definitions:
|
|
601
|
+
|
|
602
|
+
[source,shell]
|
|
603
|
+
----
|
|
604
|
+
# Validate a definition file
|
|
605
|
+
ukiryu validate --definition /path/to/tool.yaml
|
|
606
|
+
|
|
607
|
+
# Validate with executable testing
|
|
608
|
+
ukiryu validate --definition /path/to/tool.yaml --executable
|
|
609
|
+
|
|
610
|
+
# Validate all definitions in register
|
|
611
|
+
ukiryu validate all
|
|
612
|
+
----
|
|
613
|
+
|
|
614
|
+
=== Check Tool Availability
|
|
615
|
+
|
|
616
|
+
[source,shell]
|
|
617
|
+
----
|
|
618
|
+
# Check if tool is available
|
|
619
|
+
ukiryu which imagemagick
|
|
620
|
+
|
|
621
|
+
# Show tool information
|
|
622
|
+
ukiryu info imagemagick
|
|
623
|
+
|
|
624
|
+
# List available tools
|
|
625
|
+
ukiryu list
|
|
626
|
+
----
|
|
627
|
+
|
|
628
|
+
// See Also
|
|
629
|
+
== See Also
|
|
630
|
+
|
|
631
|
+
* link:/reference/configuration-options[Configuration Options] - Environment variables and config
|
|
632
|
+
* link:/interfaces/ruby-api[Ruby API] - Error handling in Ruby API
|
|
633
|
+
* link:/interfaces/cli[Command Line Interface] - CLI error messages
|
|
634
|
+
* link:/advanced/validating-definitions[Validating Definitions] - Using validation tools
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Reference
|
|
4
|
+
nav_order: 8
|
|
5
|
+
has_children: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
= Reference
|
|
9
|
+
|
|
10
|
+
Complete reference documentation for Ukiryu APIs, schemas, and configuration.
|
|
11
|
+
|
|
12
|
+
// Overview
|
|
13
|
+
== Overview
|
|
14
|
+
|
|
15
|
+
This section provides comprehensive reference material:
|
|
16
|
+
|
|
17
|
+
* link:/reference/tool-profile-schema[Tool Profile Schema] - Complete YAML schema reference
|
|
18
|
+
* link:/reference/configuration-options[Configuration Options] - All ENV, CLI, and API options
|
|
19
|
+
* link:/reference/error-codes[Error Codes] - Error messages and meanings
|
|
20
|
+
* link:/reference/ruby-api[Ruby API Reference] - Complete class and method documentation
|