try { Asset::css('style.css'); } catch(\Exception $e) { // do nothing }
Ben Corlett wrote on Wednesday 22nd of June 2011:It's great that it throws an exception. if you get too scared by knowing that your assets aren't being loaded just put the whole lot in a try / catch
try { Asset::css('style.css'); } catch(\Exception $e) { // do nothing }
Andres Vidal wrote on Wednesday 22nd of June 2011:Thank you Jelmer for the feedback... I completely agree that these resources are not "optional" in the sense of development or deliverables. I too appreciate the Exception informing me that something is missing or wrong. However, with that said, let me explain my reasoning. I manage a team of 7 front-end developers and work for one of the worlds largest photography and video company. We have a very large and complicated infrastructure. Our typical migration process involves moving application (logic) files first and then static files (CSS, JS, IMAGES) second. This is largely in part to session and cart handling. In a very rare occasion and within a fraction of a minute, a user might face new application logic without corresponding static files. We take extreme care to avoid this, but, in theory it could happen. In our tests, the user would simply be "missing" the CSS, JS, or IMAGES but continues to work seamlessly. On the next page load or refresh, all the static files would catch up. Our biggest headaches are with extremely important JS that handles critical tasks. Our most important goal is to stay transparent while still handling users that use IE 5. From my research, user's don't care about the website's aesthetics or why something is broken. If it functions for their needs then they just want to finish what they came for and get out. Like you said, considering this scenario and if we were using something like fuelPHP, we would need to extend Asset to prevent the Exception from crashing the user's session or flow. On the other hand, if this is a possible situation for any application, then I thought, offering a silent error log message is better than extending the Asset class. I even thought of adding a "config" setting for this "feature." Either way, I offer this advice out of pure appreciation for the hard work you guys have done. I really like what this framework has accomplished in such a short time!
// Replace return parent::render($group, $raw = false); // With return parent::render($group, $raw);
Andres Vidal wrote on Tuesday 21st of June 2011:I made a mistake with Asset::css() and it returned a "bad" error that halted rendering. Isn't a better idea to silently error by excluding the missing resource instead of causing an Exception error?
It looks like you're new here. If you want to get involved, click one of these buttons!