}
/**
- * Notify of a http error.
- * Check for standard scenarios such as validation errors and
- * formats an error notification accordingly.
- * @param {Error} error
+ * Notify of standard server-provided validation errors.
+ * @param {Object} error
*/
function showValidationErrors(error) {
if (!error.status) return;
}
}
+/**
+ * Notify standard server-provided error messages.
+ * @param {Object} error
+ */
+function showResponseError(error) {
+ if (!error.status) return;
+ if (error.status >= 400 && error.data && error.data.message) {
+ emit('error', error.data.message);
+ }
+}
+
export default {
emit,
emitPublic,
success: (msg) => emit('success', msg),
error: (msg) => emit('error', msg),
showValidationErrors,
+ showResponseError,
}
\ No newline at end of file