Click here to Skip to main content
15,901,373 members
Home / Discussions / Java
   

Java

 
AnswerRe: I want help Pin
Andrei Straut1-Aug-12 23:03
Andrei Straut1-Aug-12 23:03 
QuestionThorwing Exception to the calling function from other class Pin
muhammed_k31-Jul-12 23:00
muhammed_k31-Jul-12 23:00 
GeneralRe: Throwing Exception to the calling function from other class Pin
Andrei Straut31-Jul-12 23:38
Andrei Straut31-Jul-12 23:38 
AnswerRe: Thorwing Exception to the calling function from other class Pin
Nagy Vilmos1-Aug-12 20:08
professionalNagy Vilmos1-Aug-12 20:08 
GeneralRe: Thorwing Exception to the calling function from other class Pin
muhammed_k2-Aug-12 6:43
muhammed_k2-Aug-12 6:43 
GeneralRe: Thorwing Exception to the calling function from other class Pin
Nagy Vilmos2-Aug-12 20:23
professionalNagy Vilmos2-Aug-12 20:23 
GeneralRe: Thorwing Exception to the calling function from other class Pin
muhammed_k2-Aug-12 21:19
muhammed_k2-Aug-12 21:19 
GeneralRe: Thorwing Exception to the calling function from other class Pin
Nagy Vilmos2-Aug-12 21:48
professionalNagy Vilmos2-Aug-12 21:48 
There is no such thing as 'global' in java.

One approach is to have an error state within a class, but this may not be appropriate. I would suggest that if you need to have a return code AND an exception then you can always return a composite class:

Java
public class ReturnState {
    private final int code;
    private final String description;
    private final Object object;
    private final Exception exception;

    public ReturnState (int code,
            String description,
            Object object,
            Exception exception) {
        this.code = code;
        this.description = description;
        this.object = object;
        this.exception = exception;
    }

    public int getCode() {
        return this.code;
    }

    public Exception getException() {
        return this.exception;
    }

    ...
}


That said, it is rare that you need BOTH so either have the return codes include errors or use exceptions.


Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

GeneralRe: Thorwing Exception to the calling function from other class Pin
muhammed_k2-Aug-12 21:55
muhammed_k2-Aug-12 21:55 
Questionaccess data stored in hashset java Pin
ahmadiss31-Jul-12 1:56
ahmadiss31-Jul-12 1:56 
Questionerror when run project jsf2.0 Pin
ahmadiss30-Jul-12 7:14
ahmadiss30-Jul-12 7:14 
AnswerRe: error when run project jsf2.0 Pin
Nagy Vilmos30-Jul-12 23:50
professionalNagy Vilmos30-Jul-12 23:50 
QuestionDesigning to interfaces? Pin
Neo1010129-Jul-12 9:52
Neo1010129-Jul-12 9:52 
AnswerRe: Designing to interfaces? Pin
BobJanova29-Jul-12 23:01
BobJanova29-Jul-12 23:01 
GeneralRe: Designing to interfaces? Pin
Neo1010129-Jul-12 23:48
Neo1010129-Jul-12 23:48 
GeneralRe: Designing to interfaces? Pin
BobJanova30-Jul-12 0:13
BobJanova30-Jul-12 0:13 
AnswerRe: Designing to interfaces? Pin
jschell30-Jul-12 5:54
jschell30-Jul-12 5:54 
Questionhow to convert java code to c# code Pin
LAPEC25-Jul-12 12:55
LAPEC25-Jul-12 12:55 
AnswerRe: how to convert java code to c# code Pin
Paul Conrad25-Jul-12 17:02
professionalPaul Conrad25-Jul-12 17:02 
GeneralRe: how to convert java code to c# code Pin
jschell27-Jul-12 12:04
jschell27-Jul-12 12:04 
GeneralRe: how to convert java code to c# code Pin
Paul Conrad27-Jul-12 14:00
professionalPaul Conrad27-Jul-12 14:00 
AnswerRe: how to convert java code to c# code Pin
BobJanova29-Jul-12 22:44
BobJanova29-Jul-12 22:44 
GeneralRe: how to convert java code to c# code Pin
kianfong27-Sep-12 21:26
kianfong27-Sep-12 21:26 
QuestionNEED GOOD JSF VIDEO TUTORIAL Pin
Gaurav Sharma from Bangalore, India24-Jul-12 20:41
Gaurav Sharma from Bangalore, India24-Jul-12 20:41 
AnswerRe: NEED GOOD JSF VIDEO TUTORIAL Pin
TorstenH.24-Jul-12 22:00
TorstenH.24-Jul-12 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.