Customize ERROR msg

@Sangram hi can we convert error to a information

Like i want to convert below msg to message like Data Not saved Please contact administrator

@Parag_Kapoor,

Use the frappe.throw(“Data Not Saved”) method in try … expept block

@makarand_b

Can you explain me in details?

On which page, I have to code?

Thanks.

@progShubham,

can you share you code ?

Yes, you can but for that, you have to make changes in framework code.
Which is result into conflicts while taking updates.
Better way you can add your custom message as @makarand_b suggested for your functionality.

@makarand_b

Actually I have set limit to a mysql table (tabItem) for max 5 only. In case of 6th insert, it throws an mysql error OperationalError: (1048, “Column ‘id’ cannot be null”).

Now I just want to show my custom error for this above error.

Thanks

You can also set the field’s length property, it will limit the number of character in the field.

1 Like

@makarand_b

I don’t have to limit the max character. I just have to limit the number of rows can be stored in a mysql table and that limiting is already done.

Now I just have to show my custom message on popup.

Thanks

@progShubham,

try the below code

try:
	// Your code
except Exception as e:
	frappe.throw("Your Custom Error Message")

@makarand_b

Can you tell me, on which .py file , I have to implement this and what to write in try block for caching Mysql error?

Thanks

@progShubham

Check Exception handling in Python

Write your method accordingly, so it will catch your exception and Where you can throw a custom message.

@Sangram @makarand_b

I know Exception handling in Python, but I’m getting MySQL error on user registration. Getting MySQL error is not an issue as I have limited the max number of rows can be inserted on ‘tabUser’ MySQL table to 5 Only.

So it results, when ever 6th user is added, it throws an MySQL error “OperationalError: (1048, "Column 'id' cannot be null").”.

Now I just want to handle this exception but I don’t know the actual .py file where user registeration is processed and inserted in ‘tabUser’ MySQL table. So I want to know the .py file name from where I can implement my logic for this MySQL exception.

If anyone can provide me the .py file name from where I can handle this exception or any other way to show my custom message for this error, It would be really helpful for me.

Thanks.