<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_dimension(dimension_id,**kwargs):
 """ Delete a dimension from the DB. Raises and exception if the dimension does not exist """

    try:
        dimension = db.DBSession.query(Dimension).filter(Dimension.id==dimension_id).one()

        db.DBSession.query(Unit).filter(Unit.dimension_id==dimension.id).delete()

        db.DBSession.delete(dimension)
        db.DBSession.flush()
        return True
    except NoResultFound:
        raise ResourceNotFoundError("Dimension (dimension_id=%s) does not exist"%(dimension_id))