...
 
Commits (2)
......@@ -12,6 +12,7 @@ import logService from './src/common/services/log.service';
import * as Sentry from '@sentry/react-native';
import { isAbort, isNetworkFail } from './src/common/helpers/abortableFetch';
import { isApiError } from './src/common/services/api.service';
import { isUserError } from './src/common/UserError';
// Init Sentry (if not running test)
......@@ -33,6 +34,10 @@ if (process.env.JEST_WORKER_ID === undefined) {
if (isAbort(hint.originalException)) {
return null;
}
// ignore user errors
if (isUserError(hint.originalException)) {
return null;
}
// only log api 500 errors
if (isApiError(hint.originalException) && hint.originalException.status < 500) {
return null;
......
import {
Alert,
} from 'react-native';
export class UserError extends Error {
constructor(...args) {
super(...args)
Alert.alert(
'',
`
${args[0]}
`,
[{
text: 'Ok',
}]
);
}
}
export const isUserError = function(err) {
return err instanceof UserError;
}
......@@ -8,6 +8,7 @@ import settingsStore from '../../settings/SettingsStore';
import * as Sentry from '@sentry/react-native';
import { isNetworkFail } from '../helpers/abortableFetch';
import { ApiError } from './api.service';
import { isUserError } from '../UserError';
const parseErrorStack = error => {
if (!error || !error.stack) {
......@@ -76,7 +77,7 @@ class LogService {
prepend = null;
}
if (!isNetworkFail(error) && (!this.isApiError(error) || this.isUnexpectedError(error))) {
if (!isNetworkFail(error) && !isUserError(error) && (!this.isApiError(error) || this.isUnexpectedError(error))) {
// report the issue to sentry
Sentry.captureException(error);
}
......
import api from './../../common/services/api.service';
import logService from './log.service';
import i18n from './i18n.service';
import { UserError } from '../UserError';
export function vote(guid, direction, data) {
return api.put('api/v1/votes/' + guid + '/' + direction, data)
......@@ -9,6 +10,6 @@ export function vote(guid, direction, data) {
})
.catch(err => {
logService.exception('[VotesService]', err);
throw new Error(i18n.t('errorMessage'));
throw new UserError(i18n.t('errorMessage'));
})
}
......@@ -18,6 +18,7 @@ import sessionService from '../../common/services/session.service';
import imagePicker from '../../common/services/image-picker.service';
import withPreventDoubleTap from '../../common/components/PreventDoubleTap';
import i18n from '../../common/services/i18n.service';
import { UserError } from '../../common/UserError';
const TouchableCustom = withPreventDoubleTap(TouchableOpacity);
......@@ -72,7 +73,7 @@ export default class ChannelSetupStep extends Component {
}
save = async () => {
if (this.store.isUploading) throw Error('Avatar is uploading, please wait');
if (this.store.isUploading) throw new UserError('Avatar is uploading, please wait');
if (!this.state.dirty) return;
payload = {
briefdescription: this.state.briefdescription,
......