- if (type != JOB_STOP && unit->load_state == UNIT_MASKED) {
- sd_bus_error_setf(e, BUS_ERROR_UNIT_MASKED,
- "Unit %s is masked.", unit->id);
- return -EADDRNOTAVAIL;
- }
+ if (type != JOB_STOP && unit->load_state == UNIT_MASKED)
+ return sd_bus_error_setf(e, BUS_ERROR_UNIT_MASKED,
+ "Unit %s is masked.", unit->id);
+
+ if (!unit_job_is_applicable(unit, type))
+ return sd_bus_error_setf(e, BUS_ERROR_JOB_TYPE_NOT_APPLICABLE,
+ "Job type %s is not applicable for unit %s.",
+ job_type_to_string(type), unit->id);