You can get more specific with status bar messages.
Use JS .contains for a string to look for certain error message you are looking for...etc etc..
Below example is for a flavor from transaction SMEN....
//Get the username entered by the user
var uName = session.findById("wnd[0]/usr/txtPersonas_2").text;
//Goto SU01
session.findById("wnd[0]/tbar[0]/okcd").text = "/nsu01";
session.findById("wnd[0]").sendVKey(0);
//Enter the username
session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").text = uName;
//Press Display
session.findById("wnd[0]/tbar[1]/btn[7]").press();
//If there is an error in status bar, come back to main screen and display the result
if(session.findById("wnd[0]/sbar").text){
 session.findById("wnd[0]/tbar[0]/btn[3]").press();
 session.findById("wnd[0]/usr/txtPersonas_4").text = "User Does not Exist";
}
else{
 //Capture the lastname
    var lname = session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSUID_MAINTENANCE:1900/txtSUID_ST_NODE_PERSON_NAME-NAME_LAST").text;
 //Go back to SMEN
 session.findById("wnd[0]/tbar[0]/okcd").text = "/n";
    session.findById("wnd[0]").sendVKey(0);
 //Paste the last name
    session.findById("wnd[0]/usr/txtPersonas_4").text = lname;
}