Mercurial Hosting > nabble
comparison src/nabble/view/web/template/ErrorNamespace.java @ 0:7ecd1a4ef557
add content
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 21 Mar 2019 19:15:52 -0600 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:7ecd1a4ef557 |
|---|---|
| 1 package nabble.view.web.template; | |
| 2 | |
| 3 import nabble.model.ModelException; | |
| 4 import nabble.naml.compiler.Command; | |
| 5 import nabble.naml.compiler.CommandSpec; | |
| 6 import nabble.naml.compiler.IPrintWriter; | |
| 7 import nabble.naml.compiler.Interpreter; | |
| 8 import nabble.naml.compiler.Namespace; | |
| 9 import nabble.naml.compiler.ScopedInterpreter; | |
| 10 import nabble.naml.namespaces.BasicNamespace; | |
| 11 import nabble.naml.namespaces.TemplateException; | |
| 12 | |
| 13 | |
| 14 @Namespace ( | |
| 15 name = "error", | |
| 16 global = false | |
| 17 ) | |
| 18 public final class ErrorNamespace extends BasicNamespace.ExceptionNamespace { | |
| 19 | |
| 20 public ErrorNamespace(TemplateException ex) { | |
| 21 super(ex); | |
| 22 } | |
| 23 | |
| 24 | |
| 25 @Namespace ( | |
| 26 name = "invalid_email_error", | |
| 27 global = false | |
| 28 ) | |
| 29 public class InvalidEmail { | |
| 30 | |
| 31 @Command public void email(IPrintWriter out,Interpreter interp) { | |
| 32 out.print(((ModelException.EmailFormat)ex).badEmail); | |
| 33 } | |
| 34 } | |
| 35 | |
| 36 public static final CommandSpec invalid_email_exception = CommandSpec.DO; | |
| 37 | |
| 38 @Command public void invalid_email_exception(IPrintWriter out,ScopedInterpreter<InvalidEmail> interp) { | |
| 39 if( ex instanceof ModelException.EmailFormat ) | |
| 40 unnamedScopedException(out,interp,new InvalidEmail()); | |
| 41 } | |
| 42 | |
| 43 | |
| 44 @Namespace ( | |
| 45 name = "bad_text_spam_error", | |
| 46 global = false | |
| 47 ) | |
| 48 public class BadSpamText { | |
| 49 | |
| 50 @Command public void text(IPrintWriter out,Interpreter interp) { | |
| 51 out.print(((ModelException.SpamException)ex).badText); | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 public static final CommandSpec spam_exception = scopedCommandSpec; | |
| 56 | |
| 57 @Command public void spam_exception(IPrintWriter out,ScopedInterpreter<BadSpamText> interp) { | |
| 58 if( ex instanceof ModelException.SpamException ) | |
| 59 scopedException(out,interp,new BadSpamText()); | |
| 60 } | |
| 61 | |
| 62 @Namespace ( | |
| 63 name = "invalid_file_error", | |
| 64 global = false | |
| 65 ) | |
| 66 public class InvalidFile { | |
| 67 | |
| 68 @Command public void filename(IPrintWriter out,Interpreter interp) { | |
| 69 out.print(((ModelException.InvalidFile)ex).fileName); | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 public static final CommandSpec invalid_file_exception = CommandSpec.DO; | |
| 74 | |
| 75 @Command public void invalid_file_exception(IPrintWriter out,ScopedInterpreter<InvalidFile> interp) { | |
| 76 if( ex instanceof ModelException.InvalidFile ) | |
| 77 unnamedScopedException(out,interp,new InvalidFile()); | |
| 78 } | |
| 79 | |
| 80 @Namespace ( | |
| 81 name = "invalid_image_error", | |
| 82 global = false | |
| 83 ) | |
| 84 public class InvalidImage { | |
| 85 | |
| 86 @Command public void filename(IPrintWriter out,Interpreter interp) { | |
| 87 out.print(((ModelException.InvalidFile)ex).fileName); | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 public static final CommandSpec invalid_image_exception = CommandSpec.DO; | |
| 92 | |
| 93 @Command public void invalid_image_exception(IPrintWriter out,ScopedInterpreter<InvalidImage> interp) { | |
| 94 if( ex instanceof ModelException.InvalidImage ) | |
| 95 unnamedScopedException(out,interp,new InvalidImage()); | |
| 96 } | |
| 97 | |
| 98 } |
