This question is very similar to [this issue][1], however I have a slight derivation.

Currently I am upserting Cases via the Data Loader, this way I can insert Cases and relate some look-up fields by their External Id.

The problem I'd like to solve is finding out if it is possible to do the following:

If a reference is found, proceed as normal. If the External Id doesn't match a value, save some other information.

Basically, is there a way to "DMLException when lookup's external id is unknown" from within a trigger?

Here is an example:

I upsert some Cases via data loader, using an External Id to populate some look-up fields. In the trigger, I handle the failures somehow. Here's what I am guessing:

    trigger CaseTrigger on Case (before insert, after insert) 
    {
    	if(Trigger.isInsert && Trigger.isBefore)
    	{
    		//If the Case used an External Id and has a success looking up its related record
    		//Do some operation
    	}
    	
    	//Not sure if the Exception gets thrown here
    	(Trigger.isInsert && Trigger.isAfter)
    	{
    		//If the Case failed due to DMLException when lookup's external id is unknown
    		List<Case> casesToFix = CaseFilter.FindCasesToFix(Trigger.New);
    		CaseHandler.FixCasesWithInvalidExernalId(fileredCases);
    	}
    }

  [1]: http://salesforce.stackexchange.com/questions/30876/prevent-dmlexception-when-lookups-external-id-is-unknown/30884#30884 "this"