-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from projecthydra/add_filename_to_error_message
Add filename to error message
- Loading branch information
Showing
2 changed files
with
15 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
require 'active_encode' | ||
|
||
module Hydra::Derivatives::Processors | ||
class ActiveEncodeError < StandardError | ||
def initialize(status, source_path, errors = []) | ||
msg = "ActiveEncode status was \"#{status}\" for #{source_path}" | ||
msg = "#{msg}: #{errors.join(' ; ')}" unless errors.empty? | ||
super(msg) | ||
end | ||
end | ||
|
||
class ActiveEncode < Processor | ||
def process | ||
encode = ::ActiveEncode::Base.create(source_path, directives) | ||
|
||
# Wait until the encoding job is finished | ||
# while(encode.reload.running?) { sleep 10 } | ||
|
||
raise_exception_if_encoding_failed(encode) | ||
raise_exception_if_encoding_cancelled(encode) | ||
raise ActiveEncodeError.new(encode.state, source_path, encode.errors) unless encode.completed? | ||
|
||
# TODO: call output_file_service with the output url | ||
end | ||
|
||
def raise_exception_if_encoding_failed(encode) | ||
return unless encode.failed? | ||
raise StandardError.new("Encoding failed: #{encode.errors.join(' ; ')}") | ||
end | ||
|
||
def raise_exception_if_encoding_cancelled(encode) | ||
return unless encode.cancelled? | ||
raise StandardError.new("Encoding cancelled: #{source_path}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters