aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/frontend/FrontendError.java
blob: 4a13c0a8db83efd7377ebc44ba28b1d2ea55f271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * 
 */
package uk.org.ury.frontend;

import javax.swing.JOptionPane;

/**
 * Factory for descriptive error dialogues.
 * 
 * @author  Matt Windsor
 *
 */

public class FrontendError
{
  private final static String FATAL_TITLE = "Unrecoverable Error";
  
  private final static String FATAL_PREFIX = 
  "An unrecoverable error has occurred, and the program must close "
  + "immediately.\n"
  + "Any unsaved work may have been permanently lost.\n\n"
  + "Please let URY Computing know about this error.\n\n"
  + "The error message reported was:\n\t";
  
  private final static String FATAL_SUFFIX = "";
  
  
  /** 
   * Create an error dialogue to report a fatal error.
   * 
   * @param message  The message, eg the exception message, 
   *                 to report to the user.
   */
  
  public static void
  reportFatal (String message, FrontendFrame frame)
  {
    // TODO: Log
    
    // TODO: Replace with bespoke error dialogue?
    
    JOptionPane.showMessageDialog (frame, 
        FATAL_PREFIX + message + FATAL_SUFFIX, 
        FATAL_TITLE,
        JOptionPane.ERROR_MESSAGE);
    
    System.exit (-1);
  }


  public static void
  reportFatal (String message, FrontendApplet panel)
  {
    // TODO: Log
    
    // TODO: Error dialogue
    
    System.out.println (message);
  }
}