oc icon indicating copy to clipboard operation
oc copied to clipboard

Handling failed render in oc-client

Open zoilorys opened this issue 7 years ago • 2 comments

So there is pretty much no way to tell that component failed to render for some reason, outside of error in console, but thats not really helpful.

The whole solution will be something like

// oc-client.js:382
oc.renderByHref($component.attr('href'), function(err, data){
    if(err || !data){
-      $component.html('');
+     $component
+         .attr('data-rendering', 'false')
+         .attr('data-rendered', 'false')
+         .html('');
+      oc.events.fire('oc:failed', { originalError: err, data: data });
        logger.error(err);
        return callback();
    }

    processHtml($component, data, callback);
});

zoilorys avatar May 26 '17 10:05 zoilorys

@zoilorys sorry for the huge delay on answering to this. I think your idea of firing a new event with the details is very good. Would you be able to attempt a PR with this? Thanks!

matteofigus avatar Jun 14 '17 00:06 matteofigus

@zoilorys I like the idea. FYI: we recently moved the oc-client-browser code in its own repo -> https://github.com/opencomponents/oc-client-browser/ would you like to attempt a PR there? Happy to help if you need anything to make this happen!

nickbalestra avatar Jul 23 '17 21:07 nickbalestra