Ticket #90 (closed enhancement: fixed)

Opened 1 month ago

Last modified 1 month ago

Null exception management, part 2

Reported by: petemounce Assigned to: louis.dejardin
Priority: major Component: Spark Core
Version: Keywords:
Cc:

Description

re: #76, please can we have a config switch to turn off this behaviour depending on build configuration or some view-engine configuration parameter? We want to fail-fast in development/staging environment, and probably turn this on in production.

Would it be a related change to make the view throw if any of the items defined in viewdata are null (when they are not nullable)? My expectation is that the controller needs to provide all of the items I define to the view - thus if something is missing/null, I would like a big fat exception (by _default_). I would also like syntax to allow me to define something in viewdata, and allow it to be null.

Attachments

90-make-strictness-of-syntax-checking-configurable.patch (42.1 kB) - added by petemounce on 11/30/08 14:39:22.

Change History

11/27/08 16:34:29 changed by petemounce

Lou; don't spend any time on this. I'll implement it and submit a patch.

11/27/08 16:34:33 changed by petemounce

  • owner set to petemounce.

11/30/08 14:39:22 changed by petemounce

  • attachment 90-make-strictness-of-syntax-checking-configurable.patch added.

11/30/08 14:55:53 changed by petemounce

The patch (against r256): * Adds a configuration attribute to the compiler element, "NullBehaviour?". NullBehaviour? can be "Strict" or "Lenient". Omitting it makes it default to "Lenient", which makes Spark behave as pre-patch. ** Propagates the configuration to the ** Adds attendant functionality (the fluent interface bits, the parsing bits, the default-value) ** Adds tests to cover these changes * Modifies the behaviour of GeneratedCodeVisitor? (for CSharp; I don't know Ruby or Python syntax for achieving the feature, though I have provided their engines with the same parameter from config) such that now if the configured to be strict, Visit(SendExpressionChunk? chunk) will render C# to throw an ArgumentNullException? instead of swallowing it or rendering the literal to the output. This is intended so that in a development environment, views will fail-fast, and the developer will be forced to correct errors sooner. ** Exception stack trace should be maintained via the overload to ANEx chosen ** Adds tests to cover these changes (to the Castle MonoRail? integration tests only; I'm not familiar with ASP.NET MVC). In so doing, refactored the test-fixture to extract a base class and then use a template method to initialise the view factory under test.

So - just the first thing that I asked for, then ;-)

11/30/08 14:56:50 changed by petemounce

  • owner changed from petemounce to louis.dejardin.

11/30/08 19:00:03 changed by louis.dejardin

  • status changed from new to closed.
  • resolution set to fixed.

(In [257]) Applied patch from Pete Mounce Closes #90 Configurable Null exception behaviour

Default is Lenient, which will not interrupt page output. Strict will throw ArgumentNullException? whose message contains the throwing ${expression}. Usage:

<spark>

<compilation nullBehaviour="Lenient|Strict"/>

</spark>

or

SparkSettings? settings; settings.SetNullBehaviour?(NullBehaviour?.Lenient | NullBehaviour?.Strict);