Fix handling of errors for downloading Overdrive Read format
authorSteven Chan <steven3416@gmail.com>
Mon, 15 Sep 2014 18:33:57 +0000 (11:33 -0700)
committerSteven Chan <steven3416@gmail.com>
Mon, 15 Sep 2014 18:33:57 +0000 (11:33 -0700)
These sort of errors require parameters to be included with the
error-handling URL, and a different format for the notification box.

Signed-off-by: Steven Chan <steven3416@gmail.com>
src/od_action.coffee
src/overdrive.coffee

index 8b330a1..a524544 100644 (file)
@@ -451,10 +451,9 @@ define [
                                                        type: type
                                } = format
 
-                               x = encodeURIComponent window.location.href
                                href = href
-                                       .replace /\{errorpageurl\}/, x
-                                       .replace /\{odreadauthurl\}/, x
+                                       .replace /\{errorpageurl\}/, encodeURIComponent window.location.href
+                                       .replace /\{odreadauthurl\}/, encodeURIComponent "#{window.location.href}&reserveid=[RESERVE_ID]&read_error=[READ_ERROR]"
 
                                action = format.linkTemplates.downloadLink
                                $.extend action, _of: $tr, _name: n, _id: id, href: href
index ad440a6..ace8f18 100644 (file)
@@ -383,10 +383,17 @@ require [
                        # If there is an error message embedded in the search parameters
                        # that resulted from an attempt at downloading content, show it in
                        # a floating notification box.
-                       if code = search_params 'ErrorCode'
+                       if code = search_params 'read_error'
+                               $('<div>')._notify 'Error message', """
+                                       <p>Could not get content</p>
+                                       <div>Error code: #{code}</div>
+                                       <div>Reserve ID: #{search_params 'reserveid'}</div>
+                                       """
+                       else if code = search_params 'ErrorCode'
                                $('<div>')._notify 'Error message', """
                                        <p>#{search_params 'ErrorDescription'}</p>
-                                       <p>Details: #{search_params 'ErrorDetails'}</p>
+                                       <div>Error code: #{code}</div>
+                                       <div>Details: #{search_params 'ErrorDetails'}</div>
                                        """
 
                        # Rewrite the text in the warning box to distinguish physical items from e-items