2
// error.cs: Error handling code for bmac/btouch
5
// Rolf Bjarne Kvinge <rolf@xamarin.com
6
// Sebastien Pouliot <sebastien@xamarin.com>
8
// Copyright 2012 Xamarin, Inc.
13
using System.Collections.Generic;
17
// BI0xxx the generator itself, e.g. parameters, environment
18
// BI1xxx code generation
20
// BI1001 Do not know how to make a trampoline for {0}
21
// BI1002 Unknown kind {0} in method '{1}'
22
// BI1003 The delegate method {0}.{1} needs to take at least one parameter
23
// BI1004 The delegate method {0}.{1} is missing the [EventArgs] attribute (has {2} parameters)
24
// BI1005 EventArgs in {0}.{1} attribute should not include the text `EventArgs' at the end
25
// BI1006 The delegate method {0}.{1} is missing the [DelegateName] attribute (or EventArgs)
26
// BI1007 Unknown attribute {0} on {1}
27
// BI1008 [IsThreadStatic] is only valid on properties that are also [Static]
28
// BI1009 No selector specified for method `{0}.{1}'
29
// BI1010 No Export attribute on {0}.{1} property
30
// BI1011 Do not know how to extract type {0}/{1} from an NSDictionary
31
// BI1012 No Export or Bind attribute defined on {0}.{1}
32
// BI1013 Unsupported type for Fields (string), you probably meant NSString
33
// BI1014 Unsupported type for Fields: {0}
34
// BI1015 In class {0} You specified the Events property, but did not bind those to names with Delegates
35
// BI1016 The delegate method {0}.{1} is missing the [DefaultValue] attribute
36
// BI1017 Do not know how to make a signature for {0}
37
// BI1018 No [Export] attribute on property {0}.{1}
38
// BI1019 Invalid [NoDefaultValue] attribute on method `{0}.{1}'
39
// BI1020 Unsupported type {0} used on exported method {1}.{2}
40
// BI1021 Unsupported type for read/write Fields: {0}
41
// BI1022 Model classes can not be categories
43
// BI1101 Trying to use a string as a [Target]
44
// BI1102 Using the deprecated EventArgs for a delegate signature in {0}.{1}, please use DelegateName instead
54
public class BindingException : Exception {
56
public BindingException (int code, string message, params object[] args) :
57
this (code, false, message, args)
61
public BindingException (int code, bool error, string message, params object[] args) :
62
this (code, error, null, message, args)
66
public BindingException (int code, bool error, Exception innerException, string message, params object[] args) :
67
base (String.Format (message, args), innerException)
73
public int Code { get; private set; }
75
public bool Error { get; private set; }
77
// http://blogs.msdn.com/b/msbuild/archive/2006/11/03/msbuild-visual-studio-aware-error-messages-and-message-formats.aspx
78
public override string ToString ()
80
return String.Format ("{0} BI{1:0000}: {3}: {2}",
81
Error ? "error" : "warning", Code, Message, BindingTouch.ToolName);
85
public static class ErrorHelper {
87
static public int Verbosity { get; set; }
89
static public void Show (Exception e)
91
List<Exception> exceptions = new List<Exception> ();
94
CollectExceptions (e, exceptions);
96
foreach (var ex in exceptions)
97
error |= ShowInternal (ex);
100
Environment.Exit (1);
103
static void CollectExceptions (Exception ex, List<Exception> exceptions)
106
AggregateException ae = ex as AggregateException;
109
foreach (var ie in ae.InnerExceptions)
110
CollectExceptions (ie, exceptions);
119
static bool ShowInternal (Exception e)
121
BindingException mte = (e as BindingException);
126
Console.Out.WriteLine (mte.ToString ());
129
Exception ie = e.InnerException;
132
Console.Error.WriteLine ("--- inner exception");
133
Console.Error.WriteLine (ie);
134
Console.Error.WriteLine ("---");
136
Console.Error.WriteLine ("\t{0}", ie.Message);
142
Console.Error.WriteLine (e.StackTrace);
144
Console.Out.WriteLine ("error BI0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com");
145
Console.Out.WriteLine (e.ToString ());